404 error for socket.io on localhost - XAMPP - Laravel 5.5

╄→尐↘猪︶ㄣ 提交于 2019-12-10 20:47:54

问题


I am using XAMPP, Window 8.1 , Laravel 5.5 on localhost

I wrote code for broadcasting in laravel using pusher and works fine. As pusher is very costly so, I am planning to move to socket.io

Added below link in master blade.

<script src="{{ asset('socket.io-client/dist/socket.io.js') }}"></script>

Also ran this command in cmd

npm install express ioredis socket.io --save

but this shows me an error below.

If you see the screenshot, the 404 error is for url is

http://localhost:1234/socket.io/?EIO=3&transport=polling&t=M4VVdoo

but my url is

http://localhost:1234/my/learning/public/socket.io/?EIO=3&transport=polling&t=M4VVdoo

Any idea, why this is happening?


回答1:


I needed to install below packages.

npm install -g laravel-echo-server

then following the step by step instruction as give here

Finally put below code before any js file.

<script src="http://{{ Request::getHost() }}:6001/socket.io/socket.io.js"></script>



回答2:


http://localhost:1234/my/learning/public/socket.io/?EIO=3&transport=polling&t=M4VVdoo it looks as though your project directiry is not resolving correctly. This can be because of an incorrect .htaccess, mod_rewrite not being enabled, or in the case of nginx, an incorrect try files directive within a server block. I'd double those appropriate configuration and see if the problem persists there after



来源:https://stackoverflow.com/questions/48389137/404-error-for-socket-io-on-localhost-xampp-laravel-5-5

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!