1

我正在使用 laravel 5.7 版和 Beyondcode\laravel-websockets 包 v1.3 我现在面临的问题是当我在本地主机上运行它时出现此错误

WebSocket connection to 'wss://localhost/app/somekey?protocol=7&client=js&version=6.0.2&flash=false' failed: Error in connection establishment: net::ERR_CERT_AUTHORITY_INVALID

我在 bootsrap.js 中将 encrypted 更改为 false 仍然连接到 wss 而不是 ws

引导程序.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,
    encrypted: false,
    wsHost: window.location.hostname,
    wsPort: 6001,
    disableStats: true
});

广播.php 配置

'connections' => [

        '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'
            ],
        ],
4

2 回答 2

1

将此行添加到配置中,不要忘记编译

enabledTransports: ['ws'],

如果这不起作用,请尝试将 pusher.js 降级到 4.3

于 2020-05-24T10:28:58.320 回答
0

万一其他人看到这一点,一旦我停止浏览https://www.mypage.com并使用http://www.mypage.com ,我就已经解决了

只需将浏览器上的协议从 https 更改为 http

于 2021-02-24T20:47:12.647 回答