tlaverdure / laravel-echo-server

Socket.io server for Laravel Echo
MIT License
2.65k stars 512 forks source link

WebSocket connection to 'wss://mydomain.com:6001/socket.io/?EIO=3&transport=websocket' failed: WebSocket is closed before the connection is established. #528

Open S-Masoud-Emamian opened 4 years ago

S-Masoud-Emamian commented 4 years ago

Describe the bug I got this error message from frontend: WebSocket connection to 'wss://mydomain.com:6001/socket.io/?EIO=3&transport=websocket' failed: WebSocket is closed before the connection is established

To Reproduce this is my laravel-echo-server.json

{
    "authHost": "https://mydomain.com",
    "authEndpoint": "/broadcasting/auth",
    "clients": [],
    "database": "redis",
    "databaseConfig": {
        "redis": {},
        "sqlite": {
            "databasePath": "/database/laravel-echo-server.sqlite"
        }
    },
    "devMode": true,
    "host": null,
    "port": "6001",
    "protocol": "https",
    "socketio": {},
    "secureOptions": ****,
    "sslCertPath": "........",
    "sslKeyPath": "........",
    "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"
    }
}
<VirtualHost *.*.*.*:80>
  ServerName mydomain.com
    ServerAlias mail.mydomain.com www.mydomain.com
  DocumentRoot /home/mydomain/public_html
  ServerAdmin webmaster@mydomain.com
  UseCanonicalName Off
    RewriteCond %{REQUEST_URI}  ^/socket.io            [NC]
    RewriteCond %{QUERY_STRING} transport=websocket    [NC]
    RewriteRule /(.*)           ws://localhost:6001/$1 [P,L]

    ProxyPass        /socket.io/ http://localhost:6001/socket.io
    ProxyPassReverse /socket.io/ http://localhost:6001/socket.io

  ## User mydomain # Needed for Cpanel::ApacheConf
  <IfModule userdir_module>
    <IfModule !mpm_itk.c>
      <IfModule !ruid2_module>
        <IfModule !mod_passenger.c>
          UserDir disabled
          UserDir enabled mydomain
        </IfModule>
      </IfModule>
    </IfModule>
  </IfModule>

.....

Expected behavior

Additional context I'm using a SSL protocol.

iooe commented 4 years ago

@S-Masoud-Emamian Have you found a solution?