Heartbeats algorithm:
- Tunnelbroker after receiving any message from clients starts to wait for SOCKET_HEARTBEAT_TIMOUT time interval.
- If there is SOCKET_HEARTBEAT_TIMOUT time without a message - send Heartbeat and start waiting again.
- If Heartbeat was sent and there is another SOCKET_HEARTBEAT_TIMOUT time interval without any response - consider the connection unhealthy and close the socket.
From the client side:
- If there is any message from Tunnelbroker start waiting CLIENT_SOCKET_HEARTBEAT_TIMOUT.
- If there was more than CLIENT_SOCKET_HEARTBEAT_TIMOUT from the last message consider the connection unhealthy and close the socket.
CLIENT_SOCKET_HEARTBEAT_TIMOUT should be at least 2x SOCKET_HEARTBEAT_TIMOUT
This diff:
- Adds new types
- Adds logic for heartbeats
- Implements tests exclusive for Heartbeats
- Make sure heartbeats will not interfere with different tests
Depends on D9618