我的项目托管在 digitalocean 中,并且我已使用 cloudflare 将域连接到服务器。我使用 SSL。但是 WSS 连接不起作用。我收到此错误消息
WebSocket connection to 'wss://mywebsite.com/app/ABCDEFG?protocol=7&client=js&version=6.0.3&flash=false' failed: Error during WebSocket handshake: Unexpected response code: 404
我有 apache2 服务器
我的 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'),
'useTLS' => false,
'encrypted'=>true,
'host'=>'127.0.0.1',
'port'=>2053,
'scheme'=>'https',
'curl_options'=> [
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0,
]
],
],
客户端 bootstrap.js 看起来像
window.Echo = new Echo({
broadcaster: 'pusher',
key: process.env.MIX_PUSHER_APP_KEY,
cluster: process.env.MIX_PUSHER_APP_CLUSTER,
forceTLS: false,
encrypted:true,
wsHost: window.location.hostname,
wsPort: 2053,
wssPort: 2053,
disableStats: true,
enabledTransports:['ws','wss'],
});
我运行命令php artisan websockets:serve --port=2053
如果您需要任何其他信息,请写评论。有人有解决方案吗?谢谢
新错误failed: WebSocket is closed before the connection is established.