Description
In scenarios where sockets are half closed (eg, if a network cable is disconnected), WebSockets may keep sending PING messages even though the PONG responses are not received, resulting in a timeout and the following log message:
[ERROR][couchbase_manager]{BuiltInWebSocket#8} No response received after 10 sec -- disconnecting |
Analysis
1. The timedOut() function linked below only calls to close the socket when the socket life cycle state is SOCKET_OPENING.
2. From the WebSocketImpl code, It seems like the timedOut() should also call to close the socket when the socket life cycle state is SOCKET_OPENED as well. If it does that it will close the socket when the PING message is timed out.
3. I have also noticed that the following code also starts the response timeout when the state is SOCKET_OPENED. As a result, if the response timeout happens, the code will do nothing but log the same way when the PING message is timed out.
How to reproduce the issue?
1. Comment out this line in LiteCore code so that the PING message is not actually sent and that will cause the PING timeout.
2. Start a continuous replicator (I have tested it with a pull replicator) connecting to a Sync Gateway. I would recommend to set the heartbeat to 30 seconds when creating the replicator otherwise the default heartbeat will be 5 mins.
3. Wait until the replicator is IDLE and then the ping message will be sent according to the heartbeat interval set.
4. The PING message timeout is 10 seconds so wait for another 10 seconds to see the timeout and the disconnecting log message as mentioned above.
Attachments
Issue Links
- duplicates
-
CBL-5791 Socket was not called to close after receiving WebSocket PING Timeout
- Closed