Hi,
It looks like fix8 cannot sent Reset Request in proper way:
* Reset Request is not sent after received Logon confirmation
* Sent request contains BeginSeqNo tag (#7) with value that is one greater than the value extracted from fix8 persist.
I have investigated source code. I suppose that enforce() and do_state_change() methods in Session::handle_logon() are invoked in improper way:
bool Session::handle_logon(const unsigned seqnum, const Message *msg)
{
if (_state == States::st_continuous)
{
send(generate_reject(seqnum, "Already logged on"), msg->get_msgtype().c_str());
return true;
}
do_state_change(States::st_logon_received);
const bool reset_given(msg->have(Common_ResetSeqNumFlag) && msg->get<reset_seqnum_flag>()->get());
sender_comp_id sci; // so this should be our tci
msg->Header()->get(sci);
target_comp_id tci; // so this should be our sci
msg->Header()->get(tci);
SessionID id(_ctx._beginStr, tci(), sci());
if (_connection->get_role() == Connection::cn_initiator)
{
if (id != _sid)
{
glout_warn << "Inbound TargetCompID not recognised (" << tci << "), expecting (" << _sid.get_senderCompID() << ')';
if (_loginParameters._enforce_compids)
{
stop();
do_state_change(States::st_session_terminated);
return false;
}
}
enforce(seqnum, msg);
do_state_change(States::st_continuous);
}
enforce() call above cannot check message sequence number until session has not been established:
bool Session::enforce(const unsigned seqnum, const Message *msg)
{
if (States::is_established(_state))
{
if (_state != States::st_logon_received)
compid_check(seqnum, msg, _sid);
if (msg->get_msgtype() != Common_MsgType_SEQUENCE_RESET && sequence_check(seqnum, msg))
return false;
}
return true;
}
In other words sequence number check operation is not applied to Logon confirmation response. In the turn next expected sequence number of received message is incremented (see Session::process() method) and following call of Session::sequence_check() (that usually is done in Session::enforce() ) causes generate_resend_request() been passed invalid begin sequence number value.
My opinion is the sequence
enforce(seqnum, msg);
do_state_change(States::st_continuous);
in Session::handle_logon discussed above should be done in reverse order:
do_state_change(States::st_continuous);
enforce(seqnum, msg);
This allows fix8 based software to do resend requesting just after Logon confirmation and with proper begin sequence number value.
Sincerely,
Victor Kovalevich