porton
porton

Reputation: 5805

WebSocket timeout in Firefox (and Chrome)

I use PHP WebSockets.

I've set a long timeout on the server:

protected function connected ($user) {
    socket_set_option($user->socket, SOL_SOCKET, SO_RCVTIMEO, array('sec'=>7200, 'usec'=>0));
    socket_set_option($user->socket, SOL_SOCKET, SO_SNDTIMEO, array('sec'=>7200, 'usec'=>0));
}

Nevertheless Firefox disconnects after about 5 minutes. I strongly suspect that this is because a timeout in Firefox.

What is the exact value of the timeout? How my JaveScript can access it? Can I change it?

The same applies to Chrome.

Upvotes: 1

Views: 3838

Answers (1)

Prabhu
Prabhu

Reputation: 3541

What you are setting with SO_RCVTIMEO & SO_SNDTIMEO is the timeout for socket send and recv. If within the set time, the send and recv do not perform their actions, error is returned.Its not related to the disconnect you are seeing

The disconnect that you see is probably due to inactivity on the TCP connection. Either the client or the server is setting up a idle line timeout of 5 minutes. May be you should setup application level keep-alive messages to keep the TCP connection intact.

Upvotes: 2

Related Questions