Laravel-websockets: failed: Error during WebSocket handshake: Unexpected response code: 403

Created on 24 Sep 2019  路  5Comments  路  Source: beyondcode/laravel-websockets

If my project link is http://127.0.0.1/notification or http://localhost/notification then how can I use websocket? It return some errors into browser console those are

WebSocket connection to 'ws://127.0.0.1/notification:6001/app/my_app_key?protocol=7&client=js&version=5.0.1&flash=false' failed: Error during WebSocket handshake: Unexpected response code: 403

WebSocket connection to 'wss://127.0.0.1/notification:443/app/my_app_key?protocol=7&client=js&version=5.0.1&flash=false' failed: Error in connection establishment: net::ERR_CERT_AUTHORITY_INVALID

I want to run the project on xampp not by php artisan serve command then how can I solve it.

question

All 5 comments

@uncannyMBM i think it should be ws://127.0.0.1:6001/notification

@uncannyMBM Bump

I'm having the same issue on Ubuntu 20.04, PHP 7.4, Laravel 8.7.1, Websockets 1.8.

I haven't tried pushing anything to it yet as I can't even get it connect.

This is running through Laravel Forge where I opened port 6500 for any connection, I started a daemon on the server to run websockets with --port=6500

I copied the SSL paths directly from the Nginx serve block, so those are correct.

I even added wss to the dashboard template to make sure it could be accessed.

I do have some allowedOrigins ... is it possible I'm getting the 403 from that?

'allowed_origins' => [
    '*.example.org',
    'local.test'
],

Is this bad formatting for these?

I can't imagine what else can be stopping this from running.

Here is my Nginx location block:

location /app {
    proxy_pass             http://127.0.0.1:6500;
    proxy_read_timeout     60;
    proxy_connect_timeout  60;
    proxy_redirect         off;

    # Allow the use of websockets
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
}

I also tried setting the proxypass to https but got the same results.

If someone can please help.

Thanks

That was indeed the issue ...

I removed the wildcard and listed all the domains including the socket server subdomain and now she fires like a champ.

Hopefully this will help someone.

Was this page helpful?
0 / 5 - 0 ratings