gpt4 book ai didi

php - Laravel beyondcode websockets 不连接

转载 作者:搜寻专家 更新时间:2023-10-31 21:47:25 24 4
gpt4 key购买 nike

我正在使用这个 Laravel websockets package拥有我自己的 websocket 服务器。

package documentation 中所述,我有这样的配置:

.env 设置:

PUSHER_APP_ID=761772
PUSHER_APP_KEY=qwerty
PUSHER_APP_SECRET=secret
PUSHER_APP_CLUSTER=ap2

广播.php:

    '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' => '105.208.174.8', <--I did test this too
'host' => '127.0.0.1',
'port' => 6001,
'scheme' => 'https'//<--Tested with http
],
],

websockets.php:

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

bootstrap.js:

/**
* Echo exposes an expressive API for subscribing to channels and listening
* for events that are broadcast by Laravel. Echo and event broadcasting
* allows your team to easily build robust real-time web applications.
*/

import Echo from 'laravel-echo'

window.Pusher = require('pusher-js');

window.Echo = new Echo({
broadcaster: 'pusher',
key: 'qwerty',
wsHost: window.location.hostname,
wsPort: 6001,
disableStats: true,
encrypted: true,
enabledTransports: ['ws', 'wss'] //This was added from issue 86

});

This is issue number 86 in package repository

我在我的 directadmin 控制面板 中使用 letsencrypt,这是我的 SSL websockets.php 部分> 配置:

    '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,
'local_cert' => '/home/myDomain/domains/myDomain/public_html/vendor/react/socket/examples/localhost.pem',
//'local_cert' => '/usr/local/directadmin/data/users/myDomain/domains/myDomain.ir.cert',
/*
* Path to local private key file on filesystem in case of separate files for
* certificate (local_cert) and private key.
*/
//'local_pk' => null,
'local_pk' => '/usr/local/directadmin/data/users/myDomain/domains/myDomain.ir.key',

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

但是当我使用 php artisan websockets:serve 时,连接似乎有问题,myDomain.com/laravel-websockets 管理面板说:

Channel's current state is unavailable

控制台显示:

Firefox can’t establish a connection to the server at wss://myDomain.ir:6001/app/qwerty?protocol=7&client=js&version=4.3.1&flash=false.

pusher.min.js:8:6335The connection to wss://myDomain.ir:6001/app/qwerty?protocol=7&client=js&version=4.3.1&flash=false was interrupted while the page was loading.

有谁知道我的问题是什么以及我该如何解决?

最佳答案

我有同样的问题,问题是 local_certlocal_pk 的读取权限。

您可以使用 sudo php artisan websocket:serve 来尝试是否是这个问题。

如果是这种情况,请添加对文件的读取权限或使用具有 /etc/supervisor/conf.d/websockets.conf 中访问权限的用户

关于php - Laravel beyondcode websockets 不连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55699441/

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