问题
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