Details
Description
The problem: When a response to TestRequest is received too quickly, a false positive heartbeat timeout happens and causes disconnection.
In method quickfix.Session.next() there exists the following code:
if (state.isTestRequestNeeded())
{ generateTestRequest("TEST"); state.incrementTestRequestCounter(); getLog().onEvent("Sent test request TEST"); stateListener.onMissedHeartBeat(); }else if (state.isHeartBeatNeeded())
{ generateHeartbeat(); }In this code,
generateTestRequest("TEST");
sends the Test Request, a response to which can be received before line
state.incrementTestRequestCounter();
is executed.
Whenever this condition happens, there is always a false disconnect due to missed heartbeats (assuming the server does not send unsolicited heartbeats)
(why this happens:
- quickfix.SessionState.isTestRequestNeeded() returns false up until 3*[heart beat interval]
- quickfix.SessionState.isTimedOut() returns false only up until 2.4*[heart beat interval]
- state.isTimedOut() returns true before state.isTestRequestNeeded(), so another TestRequest is not sent before the timeout causes the disconnection.
Note: it is not a theoretical issue, the problem does occur time to time