Skip to content

Settings EnableNextExpectedMsgSeqNum not works well #716

Open

Description

@BingerCoder

FIXT.1.1
50SP2

When set EnableNextExpectedMsgSeqNum=Y,the tag 789 always equals to 2 when first time logon.

[DEFAULT]
SocketConnectHost=127.0.0.1
SocketConnectPort=1111
HeartBtInt=60
SenderCompID=xx
TargetCompID=xx
ResetOnDisconnect=N
ResetOnLogon=N
FileLogPath=fixlog
StartTime=04:00:00
EndTime=23:55:00

[SESSION]
BeginString=FIXT.1.1
FileStorePath=./sessions/
DefaultApplVerID=9
EnableNextExpectedMsgSeqNum=Y

@ackleymi Please check it ,thanks a lot

Activity

  1. BingerCoder commented on May 22, 2025

    @BingerCoder
    Author
    // NextTargetMsgSeqNum returns the next MsgSeqNum that should be received
    func (store *fileStore) NextTargetMsgSeqNum() int {
    	return store.cache.NextTargetMsgSeqNum()
    }
    

    ...

    // Evaluate tag 789.
    if s.EnableNextExpectedMsgSeqNum {
    	if inReplyTo != nil {
    		targetWantsNextSeqNumToBe, getErr := inReplyTo.Body.GetInt(tagNextExpectedMsgSeqNum)
    		if getErr == nil {
    			actualNextNum := s.store.NextSenderMsgSeqNum()
    			// // Is the 789 we received too high ??
    			if targetWantsNextSeqNumToBe > actualNextNum {
    				// we can't resend what we never sent! something unrecoverable has happened.
    				return RejectLogon{fmt.Sprintf("Tag 789 (NextExpectedMsgSeqNum) is higher than expected. Expected %d, Received %d", actualNextNum, targetWantsNextSeqNumToBe)}
    			}
    			nextSeqNum := s.store.NextTargetMsgSeqNum()
    			logon.Body.SetField(tagNextExpectedMsgSeqNum, FIXInt(nextSeqNum+1))
    		}
    	} else {
    		// We are sending a logon.
    		nextseqnum := s.store.NextTargetMsgSeqNum()
    		logon.Body.SetField(tagNextExpectedMsgSeqNum, FIXInt(nextseqnum+1))
    	}
    }
    

    NextTargetMsgSeqNum means next MsgSeqNum that should be received
    if it equals to the NextExpectedMsgSeq?needn't +1?

  2. BingerCoder commented on May 22, 2025

    @BingerCoder
    Author
    if s.EnableNextExpectedMsgSeqNum {
    	if inReplyTo != nil {
    		targetWantsNextSeqNumToBe, getErr := inReplyTo.Body.GetInt(tagNextExpectedMsgSeqNum)
    		if getErr == nil {
    			actualNextNum := s.store.NextSenderMsgSeqNum()
    			// // Is the 789 we received too high ??
    			if targetWantsNextSeqNumToBe > actualNextNum {
    				// we can't resend what we never sent! something unrecoverable has happened.
    				return RejectLogon{fmt.Sprintf("Tag 789 (NextExpectedMsgSeqNum) is higher than expected. Expected %d, Received %d", actualNextNum, targetWantsNextSeqNumToBe)}
    			}
    			nextSeqNum := s.store.NextTargetMsgSeqNum()
    			logon.Body.SetField(tagNextExpectedMsgSeqNum, FIXInt(nextSeqNum+1))
    		}
    	} else {
    		// We are sending a logon.
    		nextseqnum := s.store.NextTargetMsgSeqNum()
    		logon.Body.SetField(tagNextExpectedMsgSeqNum, FIXInt(nextseqnum))
    	}
    }```
    
    if inReplyTo != nil nextSeqNum+1,else nextseqnum
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions