1 month ago

Laravel-echo-server for production - WebSocket connection problem

Posted 1 month ago by rootchips

Hi, I tried to run on top of my app in production server. Using https, redis, also allow CORS and also CloudFlare. Unfortunately, it got no error on console. I also allow 2053 port in my server. These are my configurations.

My app.js

window.Echo = new Echo({
    broadcaster: '',
    host: window.location.hostname + ':2053',
    transports: ['websocket', 'polling'],
    auth: {
        headers: {
            Authorization: 'Bearer key'

My laravel-echo-server.json

    "authHost": "",
    "authEndpoint": "/broadcasting/auth",
    "clients": [
            "appId": "app-id",
            "key": "app-key"
    "database": "redis",
    "databaseConfig": {
        "redis": {
            "port": "6379",
            "host": "",
            "password": "password"
        "sqlite": {
            "databasePath": "/database/laravel-echo-server.sqlite"
    "devMode": false,
    "host": null,
    "port": "2053",
    "protocol": "https",
    "socketio": {},
    "secureOptions": 67108864,
    "sslCertPath": "/etc/ssl/certs/",
    "sslKeyPath": "/etc/ssl/private/",
    "sslCertChainPath": "",
    "sslPassphrase": "",
    "subscribers": {
        "http": true,
        "redis": true
    "apiOriginAllow": {
        "allowCors": true,
        "allowOrigin": "",
        "allowMethods": "GET, POST",
        "allowHeaders": "Origin, Content-Type, X-Auth-Token, X-Requested-With, Accept, Authorization, X-CSRF-TOKEN, X-Socket-Id"

My nginx conf

    location / {
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_set_header X-NginX-Proxy true;
            proxy_pass http://localhost:2053;
            proxy_redirect off;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";

I tried to telnet the Cloudflare URL with port 2053 and got this result

HTTP/1.1 400 Bad Request
Server: cloudflare
Date: Sat, 11 Jan 2020 13:26:27 GMT
Content-Type: text/html
Content-Length: 155
Connection: close

<head><title>400 Bad Request</title></head>
<center><h1>400 Bad Request</h1></center>
Connection closed by foreign host.

Tried to open

code: 3,
message: "Bad request"

Is there something I'm missing on my config?

Please sign in or create an account to participate in this conversation.