gpt4 book ai didi

laravel - Laravel Echo Server-Socket.io-轮询失败

转载 作者:行者123 更新时间:2023-12-03 12:08:24 26 4
gpt4 key购买 nike

Laravel Echo Server通过以下方式启动:
laravel-echo-server start并运行良好:

L A R A V E L  E C H O  S E R V E R

version 1.3.1

Starting server...

✔ Running at localhost on port 6001
✔ Channels are ready.
✔ Listening for http events...
✔ Listening for redis events...

Server ready!

CHANNEL private-user:09222583-ef73-5640-bcc8-062b36c4f380.d3d0a4d2-0c95-5f5f-aea4-1dfe1fa36483

但是,在前端,轮询似乎失败了。 “网络”选项卡显示请求不断尝试连接并失败:

enter image description here

URL看起来像这样: https://example.com:6001/socket.io/?EIO=3&transport=polling&t=MGEIXhf laravel-echo-server.json看起来像这样:
{
"authHost": "https://example.com",
"authEndpoint": "/broadcasting/auth",
"clients": [],
"database": "redis",
"databaseConfig": {
"redis": {
"host": "127.0.0.1",
"password": "56df4h5dfg4"
}
},
"devMode": false,
"host": null,
"port": "6001",
"protocol": "https",
"socketio": {},
"sslCertPath": "/etc/nginx/ssl/example_com/ssl-bundle.crt",
"sslKeyPath": "/etc/nginx/ssl/example_com/example_com.key",
"sslCertChainPath": "",
"sslPassphrase": ""
}

端口 6001似乎已在 ufw中打开:
Status: active

To Action From
-- ------ ----
...
6001 ALLOW Anywhere
...
6001 (v6) ALLOW Anywhere (v6)
...

最佳答案

确认您在js文件中也使用了相同的端口号。

import Echo from 'laravel-echo'
window.io = require('socket.io-client');
window.Echo = new Echo({
broadcaster: 'socket.io',
host: window.location.hostname + ':6001'});

关于laravel - Laravel Echo Server-Socket.io-轮询失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50897904/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com