Websockets online deployment

I am working on a web development project involving websockets. Every thing is all right on local server, using wamp server.

Problems occurred online, the dedicated server is well configured for websocket (php extension is activated) and I can run the server without any problem.

Nevertheless the connection fails, client is unable to be connected. This is not a problem of port or firewall, client can access to the server but the handshake stay uncompleted.

I use PHPWebSocket :

There isn't lots of documentation about websockets deployment on a web server, it works generaly fine in local.

If someone have encountered the same problem or have an idea of what's going wrong...

Answers


Problem solved

PHPwebsocket use IDs to differentiate client and associated sockets.

So, on the $this->read, we have some couples :

clientID => sockets

The problem is there, the function socket_select don't care about id. So depending of the implementation...

on local (Windows)

input :

{
0 => ressource #5,
1 => ressource #6
}

output :

{
**1** => ressource #6
}

online (Debian)

input :

{
0 => ressource #5,
1 => ressource #6
}

output :

{
**0** => ressource #6
}

The relation is not keep anymore on the second case, which cause a problem on the rest of the process.

To resolve that problem, I add a loop to redefined id :

foreach($this->wsRead as $id => $socket2){
    if($socket2 ==$socket)
    $clientID = $id;
    }

After the loop $clientID is set to the right value.


Need Your Help

Allow child panel to handle mouse motion events

c++ wxwidgets

I had a GUI application with the following layout:

How to setup .htaccess to rewrite to a different folder

.htaccess mod-rewrite url-rewriting

I'm moving my site to a new host but I need to have my current server continue to handle requests (not all files can be moved to the new server).