gpt4 book ai didi

laravel - Beyondcode Laravel Websockets : failed: WebSocket is closed before the connection is established

转载 作者:行者123 更新时间:2023-12-02 15:19:12 28 4
gpt4 key购买 nike

本地 websockets 运行得非常顺利,但在生产中我不断收到标题中的错误。

我正在使用 websocket 包的一些背景信息:beyondcode/laravel-websockets。我正在与主管一起运行“php artisan websockets:serve --port=6004”。我还确保端口 6004 已打开。

在生产中,我尝试了使用和不使用 SSL 的设置,都在标题中给出了错误。

SSL 设置:

我的回声设置:

window.Echo = new Echo({
broadcaster: 'pusher',
key: process.env.MIX_PUSHER_APP_KEY,
wsHost: window.location.hostname,
wsPort: 6004,
wssPort: 6004,
disableStats: true,
enabledTransports: ['ws', 'wss'],
});

我的推送器设置:

'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' => 6004,
'scheme' => 'https',
'curl_options' => [
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0,
]
],
],

我的 websocket 设置:

'apps' => [
[
'id' => env('PUSHER_APP_ID'),
'name' => env('APP_NAME'),
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'enable_client_messages' => true,
'enable_statistics' => true,
],
],

'ssl' => [
/*
* Path to local certificate file on filesystem. It must be a PEM encoded file which
* contains your certificate and private key. It can optionally contain the
* certificate chain of issuers. The private key also may be contained
* in a separate file specified by local_pk.
*/
'local_cert' => base_path().'/ssl/server.crt',

/*
* Path to local private key file on filesystem in case of separate files for
* certificate (local_cert) and private key.
*/
'local_pk' => base_path().'/ssl/server.pem',

/*
* Passphrase for your local_cert file.
*/
'passphrase' => null,
'verify_peer' => false,
],

不使用 SSL 的设置:

我的回声设置:

window.Echo = new Echo({
broadcaster: 'pusher',
key: process.env.MIX_PUSHER_APP_KEY,
wsHost: window.location.hostname,
wsPort: 6004,
disableStats: true,
enabledTransports: ['ws', 'wss'],
});

我的推送器设置:

'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' => false,
'host' => '127.0.0.1',
'port' => 6004,
'scheme' => 'http',
],
],

我的 websocket 设置:

'apps' => [
[
'id' => env('PUSHER_APP_ID'),
'name' => env('APP_NAME'),
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'enable_client_messages' => true,
'enable_statistics' => true,
],
],

'ssl' => [
/*
* Path to local certificate file on filesystem. It must be a PEM encoded file which
* contains your certificate and private key. It can optionally contain the
* certificate chain of issuers. The private key also may be contained
* in a separate file specified by local_pk.
*/
'local_cert' => null,

/*
* Path to local private key file on filesystem in case of separate files for
* certificate (local_cert) and private key.
*/
'local_pk' => null,

/*
* Passphrase for your local_cert file.
*/
'passphrase' => null,

],

最佳答案

就我而言,将 Pusher 从 6 降级到

"pusher-js": "^4.3.1"

它开始工作了。 JavaScript 我爱你! 😠

关于laravel - Beyondcode Laravel Websockets : failed: WebSocket is closed before the connection is established,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58247904/

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