'socket.io laravel echo not working in production in ubuntu

I'm using socket.io and laravel echo server with Redis and also SSL installed on the server but the socket.io file is not loading on the production ubuntu server everything works fine in my local window I'm not sure if I need any other configurations for production I also allow UFW 6001 port.

this is my laravel-echo-server.json file.

{
"authHost": "https://flowerful.initialengine.com",
"authEndpoint": "/broadcasting/auth",
"clients": [
    {
        "appId": "bb6e18dd7fd2e7aa",
        "key": "c52b04fae249d3cb303b317b281b1599"
    }
],
"rejectUnauthorized": false,
"database": "redis",
"databaseConfig": {
    "redis": {},
    "sqlite": {
        "databasePath": "/database/laravel-echo-server.sqlite"
    }
},
"devMode": true,
"host": null,
"port": "3001",
"protocol": "https",
"socketio": {},
"secureOptions": 67108864,
"sslCertPath": "/etc/letsencrypt/live/flowerful.initialengine.com/fullchain.pem",
"sslKeyPath": "/etc/letsencrypt/live/flowerful.initialengine.com/privkey.pem",
"sslCertChainPath": "",
"sslPassphrase": "",
"subscribers": {
    "http": true,
    "redis": true
},
"apiOriginAllow": {
    "allowCors": true,
    "allowOrigin": "https://flowerful.initialengine.com",
    "allowMethods": "GET, POST",
    "allowHeaders": "Origin, Content-Type, X-Auth-Token, X-Requested-With, Accept, Authorization, X-CSRF-TOKEN, X-Socket-Id"
}

}

this is laravel echo server running on the production server.

I search on different portals and get some help and I apply some things following.

  1. Allow ufw port 6001
  2. run command laravel-echo-server init and create a config file
  3. give SSL the right paths

Some things in my mind may be happening. I installed virtual host may be apache2 not allow the domain to run on 6001 port

the URL is that is not working.

https://flowerful.initialengine.com:6001/socket.io/?EIO=3&transport=polling&t=NLFfgwB

enter image description here

Console window browser



Solution 1:[1]

I think you should generate and set the right SSL file with .cert and '.key' extension for laravel-echo-server config like this:

"sslCertPath": "/{path_of_ssl}/flowerful.initialengine.com.cert.combined",
"sslKeyPath": "/{path_of_ssl}/flowerful.initialengine.com.key",

Solution 2:[2]

In my case, just port 6001 was closed. Check on server is project serve on your port:

curl -I localhost:6001

If you receive http headers, that mean is all ok and you need just open port.

For open port:

iptables -I INPUT -p tcp --dport 6001 --syn -j ACCEPT
service iptables save

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2