Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Laravel websockets connection failed on production server #783

@sts-ryan-holton

Description

@sts-ryan-holton

I've got a Laravel 8 API project along with a Nuxt JS front-end that uses Laravel Echo. I'm installed the Laravel Websockets server and have everything working just fine with the Pusher replacement config:

'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' => true,
        'host' => '127.0.0.1',
        'port' => 6001,
        'scheme' => 'http'
    ],
],

It's also worth noting here that I've also tried:

'options' => [
    ...
    'port' => 6001,
    'scheme' => 'https'
],

and...

'options' => [
    ...
    'port' => 443,
    'scheme' => 'https'
],

However, when I deploy to my CentOS 8 server and start the websockets server with php artisan websockets:serve (I'm in debug mode) and I try to connect, I'm getting a connection failed error. I'm using the default port of 6001 and default host of 0.0.0.0, the error I get from my front-end is:

WebSocket connection to 'wss://127.0.0.1/app/local?protocol=7&client=js&version=7.0.3&flash=false' failed:

My front-end is for example: https://example-gui.example.com/ whilst my running API is on https://example-api.example.com/, both on the same server, and the same server as the running websockets server.

I'm using Cloudflare for HTTPs, and I'm not sure whether I need to change anything with the host?

I originally had the connection like this:

'wss://127.0.0.1/app/local?protocol=7&client=js&version=7.0.3&flash=false', when I run netstat -tulnp I do indeed see that port 6001 is in there.

What am I missing to connect in production?

I'm stuck in knowing how to get it to connect!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions