[英]Laravel websockets connection failed
I've got a Laravel 8 API project along with a Nuxt JS front-end that uses Laravel Echo.我有一个 Laravel 8 API 项目以及一个使用 Laravel Echo 的 Nuxt JS 前端。 I'm installed the Laravel Websockets server and have everything working just fine with the Pusher replacement config:我安装了 Laravel Websockets 服务器,并且使用 Pusher 替换配置一切正常:
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
'encrypted' => true,
'host' => '127.0.0.1',
'port' => 6001,
'scheme' => 'http'
],
],
It's also worth noting here that I've also tried:这里还值得注意的是,我也尝试过:
'options' => [
...
'port' => 6001,
'scheme' => 'https'
],
and...和...
'options' => [
...
'port' => 443,
'scheme' => 'https'
],
However, when I deploy to my CentOS 8 server and start the websockets server with php artisan websockets:serve
(I'm in debug mode) and I try to connect, I'm getting a connection failed error.但是,当我部署到 CentOS 8 服务器并使用php artisan websockets:serve
启动 websockets 服务器(我处于调试模式)并尝试连接时,我收到连接失败错误。 I'm using the default port of 6001
and default host of 0.0.0.0
, the error I get from my front-end is:我正在使用默认端口6001
和默认主机0.0.0.0
,我从前端得到的错误是:
WebSocket connection to 'wss://127.0.0.1/app/local?protocol=7&client=js&version=7.0.3&flash=false' failed: WebSocket 连接到 'wss://127.0.0.1/app/local?protocol=7&client=js&version=7.0.3&flash=false' 失败:
My front-end is for example: https://example-gui.example.com/ whilst my running API is on https://example-api.example.com/ , both on the same server, and the same server as the running websockets server.例如,我的前端是: https://example-gui.example.com/而我正在运行的 API 位于https://example-api.example.com/上,并且与服务器相同,正在运行的 websockets 服务器。
I'm using Cloudflare for HTTPs, and I'm not sure whether I need to change anything with the host?我将 Cloudflare 用于 HTTPs,但我不确定是否需要对主机进行任何更改?
I originally had the connection like this:我最初有这样的连接:
'wss://127.0.0.1/app/local?protocol=7&client=js&version=7.0.3&flash=false', when I run
netstat -tulnp
I do indeed see that port6001
is in there. 'wss://127.0.0.1/app/local?protocol=7&client=js&version=7.0.3&flash=false',当我运行netstat -tulnp
时,我确实看到端口6001
在那里。
What am I missing to connect in production?我在生产中缺少什么连接?
I'm stuck in knowing how to get it to connect!我被困在知道如何让它连接!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.