php 在生产(Ubuntu 20.04.4)中,Laravel WebSockets中的通道当前状态不可用

kknvjkwl  于 2022-12-21  发布在  PHP
关注(0)|答案(1)|浏览(154)

我正在尝试在larvel-9.0项目上设置websockets。当我尝试打开/laravel-websockets时,我在控制台中收到以下错误。项目是在Ubuntu 20.04.4上设置的。
Web套接字连接到“wss://dev.mydomain.in:6001/app/mywebsocketkey?protocol=7&client=js&version=4.3.1&flash=false”失败:
我得到了一个成功的响应时,我正试图连接这通过 Postman 与url
wss://dev.mydomain.in:6001/app/mywebsocketkey?protocol=7&client=js&version=4.3.1&flash=false
我在 Postman 那里得到了以下的回应。

{
    "event": "pusher:connection_established",
    "data": "{\"socket_id\":\"371175048.259495464\",\"activity_timeout\":30}"
}

我已经关注了Websockets documentation
以下是***broadcast.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'),
                'useTLS' => true,
                'encrypted' => true,
                'host' => 'dev.mydomain.in',
                'port' => 6001,
                'scheme' => 'https',
                'curl_options' => [
                    CURLOPT_SSL_VERIFYHOST => 0,
                    CURLOPT_SSL_VERIFYPEER => 0,
                ]
            ],
            'client_options' => [
                // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
            ],
        ],

网络套接字. php

'apps' => [
        [
            'host' => env('LARAVEL_WEBSOCKETS_HOST', "127.0.0.1"),
            'port' => env('LARAVEL_WEBSOCKETS_PORT', 6001),
            'id' => env('PUSHER_APP_ID'),
            'name' => env('APP_NAME'),
            'key' => env('PUSHER_APP_KEY'),
            'secret' => env('PUSHER_APP_SECRET'),
            'path' => env('PUSHER_APP_PATH'),
            'capacity' => null,
            'enable_client_messages' => true,
            'enable_statistics' => true,
            'encrypted' => true
        ],
    ],

*** Bootstrap . js***

import Echo from "laravel-echo"

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

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

.环境

PUSHER_APP_ID=1234
PUSHER_APP_KEY=mywebsocketkey
PUSHER_APP_SECRET=hjhasjdhajsh
PUSHER_APP_CLUSTER=mt1
LARAVEL_WEBSOCKETS_HOST="dev.mydomain.in"
LARAVEL_WEBSOCKETS_PORT=6001
LARAVEL_WEBSOCKETS_SSL_LOCAL_CERT="/usr/dev/ssl-fullchain.pem"
LARAVEL_WEBSOCKETS_SSL_LOCAL_PK="/usr/dev/ssl.key"
LARAVEL_WEBSOCKETS_SSL_PASSPHRASE=null
qfe3c7zg

qfe3c7zg1#

尝试在.env文件中为PUSHER_APP_ID PUSHER_APP_KEY和PUSHER_APP_SECRET设置相同的值

相关问题