我使用的是laravel版本5.7和除了beyondcode\laravel-websockets package v1.3。我现在面临的问题是,当我在localhost上运行它时,我收到以下错误
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
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,
encrypted: false,
wsHost: window.location.hostname,
wsPort: 6001,
disableStats: true
});broadcasting.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'
],
],发布于 2020-05-24 18:28:58
将这一行添加到config中,不要忘记编译
enabledTransports: ['ws'],如果这不起作用,可以尝试将pusher.js降级到4.3
发布于 2021-02-25 04:47:13
为了防止其他人看到这一点,我已经在停止使用https://www.mypage.com并使用http://www.mypage.com之后解决了这个问题
只需将浏览器上的协议从https更改为http
https://stackoverflow.com/questions/61867580
复制相似问题