1

I'm running an app, where I use laravel-websockets, with the pusher replacement and a self created websocket instance. For SSL I used a letsencrypt certificate and the nginx reverse proxy "Same location for websockets and web contents" approach. On my nginx TLS 1.2 and 1.3 is enabled. Now on Firefox and Chrome all is working fine, but on Safari (version 14.1.2, tested on a macOS Mojave 10.14.6) I get the following error in the console:

WebSocket connection to 'wss://example.com/app/asdfasdf?protocol=7&client=js&version=7.0.3&flash=false' failed: Unexpected response code: 401

These are my echo options:

const echoOptions = {
  broadcaster: 'pusher',
  key: process.env.MIX_PUSHER_APP_KEY,
  cluster: process.env.MIX_PUSHER_APP_CLUSTER,
  wsHost: window.location.hostname,
  wsPort: 80,
  wssPort: 443,
  forceTLS: true,
  enabledTransports: ['ws', 'wss'], // <-- disable pusher api fallback
  disableStats: true,
};

window.Echo = new Echo(echoOptions);

I searched a lot for any kind of similar issues, but I can't find an answer.

Any ideas or help would be awesome!

Zacharias
  • 57
  • 9

1 Answers1

1

I finally figgered it out:

In the "getting started" installation section mentioned here: https://beyondco.de/docs/laravel-websockets/getting-started/installation

They say install the latest stable version with:

composer require beyondcode/laravel-websockets

This installs version 1.12.0

To fix this issue I just removed the stable version and installed the latest beta:

composer remove beyondcode/laravel-websockets
composer require beyondcode/laravel-websockets "2.0.0-beta.36"

I had some dependencies that can't be resolved, so I needed to downgrade doctrine/dbal from version 3.1 to 2.9.

Then I backed up my old config/websocket.php and published the new one of the new package with:

cp config/websocket.php config/websocket.old.php
rm config/websocket.php
php artisan vendor:publish --provider="BeyondCode\LaravelWebSockets\WebSocketsServiceProvider" --tag="config"

There I adjusted some values, e.g. allowed_origin and enable_client_messages.

Finally don't forget to kill to old websockets:serve process (if its running) by searching the process id with ps aux | grep websocket and restart the websocket with:

kill <process id>
php artisan websockets:serve

PS: I also updated pusher/pusher-php-server to version 5.0 not 3.0 as they mentioned here and used the lates npm pusher-js package 7.0.3

Zacharias
  • 57
  • 9