在 QuickFIX 接受器中自定义 FIX 登录过程
我正在使用 QuickFIX 和 C# 创建 FIX 接受器(服务器)。我希望客户端(FIX 发起者)使用用户名和密码登录。但是,我不确定如何在 QuickFIX 中做到这一点。
通过调试 QuickFIX 源代码,我发现了以下事件序列:
- QuickFIX 将调用
Session::verify
来验证登录。 Session::verify
将执行各种检查,例如组件 ID 和序列号,并在某个时刻确定收到的登录是否有效。- 然后,
Session::verify
将调用Application::fromAdmin
回调,我认为这是自定义登录等内容的自然位置。 - 然而,此时 QuickFIX 已经确定登录成功,并且当回调返回时,接受器将返回相应的登录消息。
如何在接受器中自定义 FIX 登录过程?修改 QuickFIX 代码是我唯一的选择吗?
I'm using QuickFIX and C# to create a FIX acceptor (server). I want the client (the FIX initiator) to logon using a username and password. However, I'm not sure how I can do that in QuickFIX.
By debugging into the QuickFIX source code I have discovered the following sequence of events:
- QuickFIX will call
Session::verify
to verify the logon. Session::verify
will perform various checks of things like comp ID's and sequence numbers and at some point determine that the logon received is valid.Session::verify
will then call theApplication::fromAdmin
callback which I assume is the natural place to customize things like logon.- However, at this point the logon has already been determined to be OK by QuickFIX and a corresponding logon message will be returned by the acceptor when the callback returns.
How do I customize the FIX logon process in an acceptor? Is modifying the QuickFIX code my only option?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您使用的是 FIX 4.3 或更高版本,登录消息可能包含 密码标签。如果您使用的是以前的版本,请将其设为自定义标签并将其添加到词典中。
在
fromAdmin
处理程序中,检查密码是否正确(从查找表或其他地方)。如果不是,则抛出RejectLogon
例外。如果未引发此异常,QuickFix 将假定一切正常并让用户登录。示例(需要更多健全性检查):
If you are using FIX 4.3 or later, the Logon message can have a Password tag. If you are using a previous version, make it a custom tag and add it to the dictionaries.
In the
fromAdmin
handler, check that the password is correct (from a lookup table or elsewhere). If it is not, throw aRejectLogon
exception. If this exception isn't thrown, QuickFix will assume everything is a-ok and log the user on.Example (needs more sanity checks):
会话验证通常检查 FIX 开始字符串、SenderCompID 和目标 CompID。如果这 3 个都很好,则会话已建立(QuickFIXJ 还有其他字段也用于子组件 ID)。
即使在会话已设置之后,对于该特定会话,接收方也不会接受消息,直到登录过程完成为止。如果您尝试这样做,您将被拒绝。
因此,在 fromAdmin 中,您可以检查传入的登录消息请求,并检查登录消息中包含的您期望该连接/会话的有效密码。
Session verification generally ckecks for the FIX Begin String, SenderCompID and target CompID. If this 3 are fine then session is set up(QuickFIXJ has other fields also for subcomp ids).
Even after Session has been set up messages wouldn't be accepted at the acceptor, for that specific session, till logon process has been completed. You will get a reject if you try so.
So in fromAdmin you can check for the incoming logon message request and check for the valid password, contained in the logon message, you expect for that connection/session.
抛出 RejectLogon QuickFIXException 会破坏整个代码并中断其余会话(如果您确实有多个会话)。
就我自己而言,我编写了一条注销消息并将其发送回对方。代码会是这样的:
Throwing a RejectLogon QuickFIXException breaks the whole code and interrupts the rest of the sessions (if you do have more than one).
In my own case, I compose a logout message and have it sent back to the counterparty. Code would be something like this: