Laravel Echo 尝试连接 wss 而不是 ws

Laravel Echo tries to connect wss instead ws

我正在使用 Pusher Laravel Webaockets 包的替代品。

在我的应用程序中 Laravel Echo 尝试通过 wía wss 而不是 ws 进行连接,因此它失败了。

我的resources/js/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,
    disableStats: true,
    encrypted: false,
    enabledTransports: ['ws'],
});

config/broadcasting中的广播连接。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' => false,
                'host' => '127.0.0.1',
                'port' => 6001,
                'scheme' => 'http',
            ],
        ],

我的.env:

BROADCAST_DRIVER=pusher
...
PUSHER_APP_ID=1122334455
PUSHER_APP_KEY=lkjdsofsd9f8sd98f7s9dfuosdff9s87fsuyfsd76f8s7df6
PUSHER_APP_SECRET=secret1122334455fsdf897sd98f7sd88sd7f9s8d7f
PUSHER_APP_CLUSTER=eu

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
MIX_PUERTO_WEBSOCKETS="${LARAVEL_WEBSOCKETS_PORT}"

当我的应用程序页面加载时,检查控制台我可以看到:

GET wss://localhost/app/lkjdsofsd9f8sd98f7s9dfuosdff9s87fsuyfsd76f8s7df6?protocol=7&client=js&version=6.0.3&flash=false

但是如果我 运行 http://localhost:8000/laravel-websockets 请求是通过 ws 成功的:

你能帮帮我吗?谢谢

将pusher.js降级到4.3。之后不要忘记编译。