Skip to content

Websocket connection control options

Websocket connection timeout

Websocket connection establishing timeout may be set while session creation. To do this, timeout parameter in milliseconds should be passed to createSession function:

var url = "wss://test.flashphoner.com:8443";
var tm = 1000;

Flashphoner.createSession({urlServer: url, timeout: tm}).on(SESSION_STATUS.ESTABLISHED, function (session) {
    ...
});

Client will receive the SESSION_STATUS.FAILED event if server does not accept connection in this time.

Websocket ping timeouts and thresholds

When Websocket connection is already established, server sends ping packets periodically, every 5 seconds by default. When client receives a ping packet, it responds with a pong packet to the server.

If client does not receive a defined quantity of successive pings, the connection seems to be down and should be closed by client. If server cannot send pings or does not receive 10 successive pongs by default, the connection also seems to be down and should be closed.

The pings missing threshold is set at server side, for example

keep_alive.probes=5

In this case the corresponding session option must be used at client side

Flashphoner.createSession({urlServer: url, receiveProbes: 5}).on(SESSION_STATUS.ESTABLISHED, function (session) {
    ...
});

The pings sending interval is set at server side by the following parameter

keep_alive.server_interval=5000

In this case the corresponding session option must be used at client side

Flashphoner.createSession({urlServer: url, pingInterval: 5000}).on(SESSION_STATUS.ESTABLISHED, function (session) {
    ...
});