[英]beyondcode\laravel-websockets it is redirecting to wss instead of ws on localhost
I am using laravel version 5.7 and beyondcode\laravel-websockets package v1.3 the problem I am facing right now is when I am running it on localhost I am getting this error我正在使用 laravel 版本 5.7 及以后的代码\laravel-websockets package 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
I have changed encrypted to false in bootsrap.js still it connects to wss instead of ws我在 bootsrap.js 中将 encrypted 更改为 false 仍然连接到 wss 而不是 ws
bootstrap.js引导程序.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 config广播.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'
],
],
Add this line to the config,dont forget to compile将此行添加到配置中,不要忘记编译
enabledTransports: ['ws'],
If this doesnt work try to downgrade pusher.js to 4.3如果这不起作用,请尝试将 pusher.js 降级到 4.3
In case somebody else sees this, I've solved it once I stopped going through https://www.mypage.com and use http://www.mypage.com In case somebody else sees this, I've solved it once I stopped going through https://www.mypage.com and use http://www.mypage.com
Just change the protocol on your browser from https to http只需将浏览器上的协议从 https 更改为 http
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.