3

I'm creating my first websocket, it works locally with ws, now I uploaded it to a server and uploaded all files and execute the websocket from ssh.

And I get this error: WebSocket opening handshake timed out

I tried adding this line to httpd.conf

ProxyPass /wss2/ ws://xxxxxxx:12345/

but still does not work.

var conn = new WebSocket('wss://xxxxxxxxx:12345');

        conn.onopen = function(e) {
            console.log("Connection established!");
            conn.send(
                JSON.stringify({
                    'type':'socket',
                    'id':'<?php echo $this->session->id; ?>'
                })
            );
        };

This is the console error I get:

dashboard:430 WebSocket connection to 'wss://xxxxxxxxxx:12345/' failed: WebSocket opening handshake timed out
Gonzalo Garcia
  • 6,192
  • 2
  • 29
  • 32
Exale
  • 51
  • 6

2 Answers2

1

If you are using Apache web server (2.4 or above), enable these modules in httpd.conf file

  1. mod_proxy.so
  2. mod_proxy_wstunnel.so

If you don't know how to enable, use below commands

  • sudo a2enmod proxy_wstunnel
  • sudo a2enmod proxy

Then Add this setting to your httpd.conf file

ProxyPass /wss2/ ws://ratchet.mydomain.org:8888/

Use this URL in your JavaSscript call when you want a WSS connection:

var ws = new WebSocket("wss://ratchet.mydomain.org/wss2/NNN");

Restart Apache web server and make sure that your Ratchet worker (web socket connection) is open before applying the settings (telnet hostname port).

Optimaz Prime
  • 857
  • 10
  • 11
0

I solved this,

First i changed the port to 8080, (I don't think that was necessary.)

Changed the url connection to:

wss://xxxxxxxxx/wss2/:8080

('Cause the ProxyPass)

And it works.

Exale
  • 51
  • 6