Laravel-websockets: WebSocket connection to remote host failed: Error during WebSocket handshake: Unexpected response code: 404

Created on 17 Jan 2019  路  4Comments  路  Source: beyondcode/laravel-websockets

Hello,

I've uploaded my to remote host and using ssh I entred: php artisan websockets:serve
and i got this errors in my client console (ionic application running on the browser):
WebSocket connection to 'wss://remote.host/app/myKey?protocol=7&client=js&version=4.3.1&flash=false' failed: Error during WebSocket handshake: Unexpected response code: 404

pusher.js:1447 WebSocket connection to 'ws://remote:host:6001/app/myKey?protocol=7&client=js&version=4.3.1&flash=false' failed: WebSocket is closed before the connection is established.

I just want to say that it was working just fine in my local machine.

Most helpful comment

It looks like your Ionic app might be running on https, websockets connection than is required to use wss protocol which is https for websockets.

You probably need to add wssPort: 6001, to your Pusher client options since it looks like it tries wss://host.com without a port number.

And if this is true the websockets server needs to support SSL to ofcourse via either the certificate added to the websockets.php configuration or some reverse proxy setup as outlined in the docs.

All 4 comments

what does remote.host resolve to?

my remote host domain name, its just something like google.com

It looks like your Ionic app might be running on https, websockets connection than is required to use wss protocol which is https for websockets.

You probably need to add wssPort: 6001, to your Pusher client options since it looks like it tries wss://host.com without a port number.

And if this is true the websockets server needs to support SSL to ofcourse via either the certificate added to the websockets.php configuration or some reverse proxy setup as outlined in the docs.

If the page you are on is in https mode then the connection to the websocket server will automatically try to use SSL and if the server is not set up for this it will fail with the messages you have shown.

If you want to use SSL I would initially suggest using the 'Usage with Laravel Valet' directions:

https://docs.beyondco.de/laravel-websockets/1.0/basic-usage/ssl.html#usage-with-laravel-valet

These directions will enable SSL, you will of course need some certificates, Let's Encrypt is a good (and free) choice if you have control over setting these up.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fridzema picture fridzema  路  4Comments

connecteev picture connecteev  路  3Comments

sudden-break picture sudden-break  路  4Comments

stefandanaita picture stefandanaita  路  4Comments

sanjarani picture sanjarani  路  5Comments