我正在尝试使用quickfix构建我的修复应用程序,但是在启动它时,它会在登录之前先发送注销消息,并引发Session Not Found。
class Application(quickfix.Application):
def __init__(self, session, logger):
super(Application, self).__init__()
self.session = session
self.logger = logger
def onCreate(self, sessionID):
self.logger.info("Created session {}.".format(sessionID))
return
def onLogon(self, sessionID):
self.logger.info("Logon session {}.".format(sessionID))
return
def onLogout(self, sessionID):
self.logger.info("Logout session {}.".format(sessionID))
return
def toAdmin(self, message, sessionID):
msgType = quickfix.MsgType()
message.getHeader().getField(msgType)
if msgType.getValue() == quickfix.MsgType_Logon:
self.logger.info('LOGON SessionID {}'.format(sessionID))
elif msgType.getValue() == quickfix.MsgType_Logout:
self.logger.info('LOGOUT SessionID {}'.format(sessionID))
self.logger.info('to Admin session {} send {}'.format(sessionID, self.messageToString(message)))
self.session.sendToTarget(message)
return
def toApp(self, message, sessionID):
self.logger.info('to App: {}'.format(message))
self.session.sendToTarget(message)
return
def fromApp(self, message, sessionID):
self.logger.info('from App: {}'.format(message))
return
logger = create_logger(config)
settings = quickfix.SessionSettings(client_config)
application = Application(quickfix.Session, logger)
storeFactory = quickfix.FileStoreFactory(settings)
logFactory = quickfix.ScreenLogFactory(settings)
initiator = quickfix.SocketInitiator(application, storeFactory, settings, logFactory)
initiator.start()
我得到以下内容:
注销SessionID FIX44:Client-> Server到Admin会话FIX44:Client-> Server发送8 = FIX.4.4 | 9 = 62 | 35 = 5 | 34 = 26 | 49 = Client | 52 = 20200608-12:26:03 | 56 =服务器| 10 = 168
文件“ FIx.py”,第42行,位于toAdmin self.session.sendToTarget(message)SessionNotFound中:找不到会话
知道为什么它会引发信息吗?
谢谢大家!
该from/toApp
或from/toAdmin
方法是回调,你应该不是自己通过发送传递消息Session.sendToTarget
。
相反,当回调返回时,消息将由quickfix发送。