localhost上的socket.io 404错误-XAMPP-Laravel 5.5 [英] 404 error for socket.io on localhost - XAMPP - Laravel 5.5
问题描述
我在本地主机上使用XAMPP,Window 8.1和Laravel 5.5
I am using XAMPP, Window 8.1 , Laravel 5.5 on localhost
我编写了用于使用pusher在laravel中进行广播的代码,并且工作正常.由于推杆非常昂贵,因此我打算移至socket.io
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>
也在cmd中运行了该命令
Also ran this command in cmd
npm install express ioredis socket.io --save
但这在下面显示了一个错误.
but this shows me an error below.
如果您看到屏幕截图,则404错误是因为url是
If you see the screenshot, the 404 error is for url is
http://localhost:1234/socket. io/?EIO = 3& transport = polling& t = M4VVdoo
但是我的网址是
http://本地主机:1234/my/learning/public/socket.io/?EIO = 3& transport = polling& t = M4VVdoo
任何想法,为什么会这样?
Any idea, why this is happening?
推荐答案
我需要安装以下软件包.
I needed to install below packages.
npm install -g laravel-echo-server
then following the step by step instruction as give here
最后将下面的代码放在任何js文件之前.
Finally put below code before any js file.
<script src="http://{{ Request::getHost() }}:6001/socket.io/socket.io.js"></script>
这篇关于localhost上的socket.io 404错误-XAMPP-Laravel 5.5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!