Search code examples
phpwebsocketphpwebsocket

WebSocket opening handshake timed out php Ratxet websocket


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

Solution

  • 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.