python - 在启动时修复 sessionNotFound
问题描述
我正在尝试使用 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()
我得到以下信息:
LOGOUT SessionID FIX44:Client->Server to Admin session FIX44:Client->Server send 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: Session Not Found
知道为什么它会引发这个消息吗?
谢谢各位!
解决方案
from/toApp
orfrom/toAdmin
方法是回调,你不应该自己通过Session.sendToTarget
.
相反,当回调返回时,消息将由 quickfix 发送。
推荐阅读
- singleton - 如何在两个窗口之间共享单例类的实例
- python-3.x - wx.ScrolledWindow 滚动条在关闭子帧后会移到顶部
- html - 如何使用一张图片作为整页背景
- typescript - 指定对象字段是枚举的属性
- javascript - Bootstrap 4 粘性顶部边距顶部
- python - 如何使用 python 请求正确地形成对该网站的 POST 请求
- sql-server - 唯一索引不起作用
- cassandra - 在 Cassandra 中订购
- knockout.js - 如果分钟/秒/毫秒为“0”,为什么 datetimepicker 会破坏年份值
- php - 在没有给定直接 IP 或域名的情况下处理服务器上的本地 php 文件