0
votes

I have a strange problem only on live server using laravel-echo-server, redis, ssl .

Error: GET https://dev.my_domain.com:6001/socket.io/?EIO=3&transport=polling&t=Ml1g-Fq net::ERR_CONNECTION_TIMED_OUT

Below you can find my configs: laravel-echo-server.json

{
    "authHost": "https://dev.my_domain.com",
    "authEndpoint": "/broadcasting/auth",
    "clients": [],
    "database": "redis",
    "databaseConfig": {
        "redis": {
            "port": "6379",
                    "host": "127.0.0.1"
        }
    },
    "devMode": true,
    "host": null,
    "port": "6001",
    "protocol": "https",
    "socketio": {},
    "sslCertPath": "/etc/letsencrypt/live/dev.my_domain.com/fullchain.pem",
    "sslKeyPath": "/etc/letsencrypt/live/dev.my_domain.com/privkey.pem"
}

Bootstrap.js

import Echo from 'laravel-echo';

window.io = require('socket.io-client');

window.Echo = new Echo({
    broadcaster: 'socket.io',
    host: window.location.hostname + ':6001'
});

Port 6001 is enabled: tcp6 0 0 :::6001 :::* LISTEN 10728/laravel-echo-

After running laravel-echo-server start

L A R A V E L  E C H O  S E R V E R

version 1.5.5

⚠ Starting server in DEV mode...

✔  Running at localhost on port 6001
✔  Channels are ready.
✔  Listening for http events...
✔  Listening for redis events...

Server ready!

It is working correctly on my localhost without ssl configuration.

Let me know if someone has a solution for this problem ,

Thanks to everyone in advance

1
Please following here, might help you. - Mr Theavuth

1 Answers

0
votes

I found a solution to my problem .

below configs seems ok now :),

First you need to update apache2 configs : Enable modules:

a2enmod proxy_wstunnel

Update apache Config Location : /etc/apache2/sites-available/**your_domain_config**.conf

Added here:

    SSLEngine on
    SSLProxyEngine On
    ProxyRequests Off
    ProxyPass        /socket.io http://dev.DOMAIN.com:6001/socket.io
    ProxyPassReverse /socket.io http://dev.DOMAIN.com:6001/socket.io

    RewriteEngine on
    RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
    RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
    RewriteRule .* ws://dev.DOMAIN.com:6001%{REQUEST_URI} [P]

Restart Apache:

systemctl restart apache2

My laravel-echo-server-json :

{
    "authHost": "https://dev.DOMAIN.com",
    "authEndpoint": "/broadcasting/auth",
    "clients": [],
    "database": "redis",
    "databaseConfig": {
        "redis": {
            "port": "6379",
            "host": "127.0.0.1"
        }
    },
    "devMode": true,
    "host": null,
    "port": "6001",
    "protocol": "https",
    "socketio": {},
    "sslCertPath": "/etc/letsencrypt/live/DOMAIN/fullchain.pem",
    "sslKeyPath": "/etc/letsencrypt/live/DOMAIN/privkey.pem"
}

Update Bootstrap.js :

import Echo from 'laravel-echo';

window.io = require('socket.io-client');

window.Echo = new Echo({
    broadcaster: 'socket.io',
    host: { path: '/socket.io' }
});