[英]Connection timed out Laravel-echo-server
I know and I have seen this question我知道并且我看过这个问题
Getting ERR_CONNECTION_TIMED_OUT Laravel echo server 获取 ERR_CONNECTION_TIMED_OUT Laravel 回显服务器
But I tried the solution in comment but it doesn't work.但我在评论中尝试了解决方案,但它不起作用。
I have my Laravel-echo-server.json我有我的 Laravel-echo-server.json
{
"authHost": "https://mysite.it",
"authEndpoint": "/broadcasting/auth",
"clients": [],
"database": "redis",
"databaseConfig": {
"redis": {
"host":"0.0.0.0",
"port":"6379",
"password": "mypwd"
},
"sqlite": {
"databasePath": "/database/laravel-echo-server.sqlite"
}
},
"devMode": true,
"host": null,
"port": "6001",
"protocol": "https",
"socketio": {},
"secureOptions": 67108864,
"sslCertPath": "path_cert" ,
"sslKeyPath": "path_key" ,
"sslCertChainPath": "",
"sslPassphrase": "",
"subscribers": {
"http": true,
"redis": true
},
"apiOriginAllow": {
"allowCors": true,
"allowOrigin": "*",
"allowMethods": "GET, PoST",
"allowHeaders": "Origin, Content-Type, X-Auth-Token, X-Requested -With, Accept, Authorization, X-CSRF-TOKEN, X-Socket-IdOrigin, Content-Type, X-A uth-Token, X-Requested-With, Accept, Authorization, X-CSRF-TOKEN, X-Socket-IdOri gin, Content-Type, X-Auth-Token, X-Requested-With, Accept, Authorization, X-CSRF -TOKEN, X-Socket-Id"
}
}
And I have in my bootstrapjs the connection with Frontend:我在我的 bootstrapjs 中有与前端的连接:
import Vue from 'vue'
import Echo from 'laravel-echo'
window.io = require('socket.io-client')
export var echo_instance = new Echo({
broadcaster: 'socket.io',
host: window.location.hostname + ':6001',
auth: {
headers: {
'Authorization': "Bearer " + localStorage.getItem('token')
}
}
})
Vue.prototype.$echo = echo_instance
export default Vue
I have check if the port was closed but with netstat -an I can see:我检查了端口是否已关闭,但使用 netstat -an 我可以看到:
tcp6 0 0 :::6001 :::* LISTEN
tcp6 0 0 :::6001 :::* 听
But when I try to launch my app i receive:但是当我尝试启动我的应用程序时,我收到:
app.js:569 GET https://mysite.it:6001/socket.io/?EIO=3&transport=polling&t=NKoWZoK net::ERR_CONNECTION_TIMED_OUT
app.js:569 GET https://mysite.it:6001/socket.io/?EIO=3&transport=polling&t=NKoWZoK net::ERR_CONNECTION_TIMED_OUT
How can I use the laravel echo with https protocol?如何将 laravel echo 与 https 协议一起使用?
this might be because you have the wrong access token(dynamically added).这可能是因为您有错误的访问令牌(动态添加)。 why don't you try using a static access token first (copy the access token and paste it instead of localStorage.getItem('token')) for the user and see if it works.
为什么不首先尝试为用户使用静态访问令牌(复制访问令牌并粘贴它而不是 localStorage.getItem('token')),看看它是否有效。
Also try putting the following in laravel-echo-server.json file还可以尝试将以下内容放入 laravel-echo-server.json 文件中
"allowOrigin": "http://mysite.it:80"
"allowOrigin": "http://mysite.it:80"
And, see if APP_URL is different in .env file并且,看看 APP_URL 在 .env 文件中是否不同
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.