Websocket server connection control¶
Since SFU SDK build 2.0.194 it is possible to check a websocket server connection consistency. WCS server sends a special ping packets periodically (every 5 seconds by default). The ping packets are received and counted by SFU SDK. If more than a certain number of consequent packets are missed, the websocket connection is supposed to be lost, and the client receives SfuEvent.CONNECTION_FAILED
event.
Connection control parameters setup in config.json
file¶
If the example reads the connection parameters from config.json
file, the maximum number of pings missing and pings checking interval may be set in the file:
Where:
failedProbesThreshold
- the maximum number of pings missingpingInterval
- pings checking interval in ms
Connection control parameters setup in a source code¶
-
roomConfig
object creation
code
let roomConfig = { url: config.room.url || "ws://127.0.0.1:8080", roomName: config.room.name || "ROOM1", pin: config.room.pin || "1234", nickname: config.room.nickName || "User1" }; if (config.room.failedProbesThreshold !== undefined) { roomConfig.failedProbesThreshold = config.room.failedProbesThreshold; } if (config.room.pingInterval !== undefined) { roomConfig.pingInterval = config.room.pingInterval; }
-
Connection establishing and the room creation
code
-
SfuEvent.CONNECTION_FAILED
event handling
code
Disabling connection control at client side¶
Sometimes pings sending may be disabled at server side
In this case, pings checking at client side should also be disabled