Skip to main content
Aug 25, 2015 4:01 AM UTC
Question

Ping Rates

Reposted from Mike Mahoney's blog:

"'Pings' are the mechanism that our websocket clients (both EMS and SDKs) use to maintain an active connection with the server.  There are two primary reasons for pings:

  1. Proxies/routers between our clients and server might automatically disconnect idle connections after some period of time.
  2. In some cases, if a TCP connection is dropped the client or server might not immediately become aware of the lost connection.  If the server expects a ping within some predefined amount of time, but does not receive one, then it can assume the connection is dead and close it.  Similarly, if a client sends a ping and does not receive a response within some amount of time, then the client can assume the connection is dead.

The server, by default, has an Idle Connection Timeout of 60 seconds (found in the WSCommunicationSubsystem).  This means that any websocket that has been inactive for 60 seconds will be closed.  Therefore, clients must send some data, or a ping message, to the server more frequently than every 60 seconds.  If the server's Idle Connection Timeout is increased, then it would be safe to increase the ping rate of the clients connected to it.  Increasing the ping rate would reduce the amount of data being sent due to pings, but would also increase the amount of time that would elapse before a dropped connection would be discovered.

The wsems also has a pingpong_timeout setting.  The EMS expects to receive a response to its pings in a timely fashion.  The default value for this field is 5000ms, meaning that if a ping is sent, and a pong is not received within 5 seconds, the EMS will close the connection and enters its reconnect loop.

The server also has a 'Idle Ping Rate' setting.  This setting is used when the server is connected to another server for federation.  In that case, the connecting server will behave like a SDK client for the purpose of pings."