由于密码丢失,QuickFix登录失败
QuickFix Login Failed due to password missing
我正在使用quickfix C++实现连接到FIX服务器,除了当我尝试连接时,它说字段缺少用户名之外,一切都很好。为了纠正这一点,我在toAdmin方法中添加了以下代码
void Application::toAdmin( FIX::Message& message, const FIX::SessionID& sessionID)
{
if (FIX::MsgType_Logon == message.getHeader().getField(FIX::FIELD::MsgType))
{
FIX44::Logon & logon_message = dynamic_cast<FIX44::Logon&>(message);
logon_message.setField(FIX::Username("username"));
logon_message.setField(FIX::Password("password"));
}
std::cout<<message.toString();
}
}
但is会导致异常。为了检查它是否工作,还尝试使用std::cout<<message.ToString();
打印消息
但什么都没用。
我想你差不多到了。以下是我在C#中用FXCM启动FIX会话的解决方案(移植C++实现应该很容易)。
1-使用QuickFix Examples.TradeClient项目。
2-确保您的fix.cfg文件存在于TradeClient/bin/Debug目录中。
3-确保您的字典(FIXFXCM10.XML)存在于TradeClient/bin/Debug目录中。
4-你的主程序.cs应该是这样的;
var settings = new QuickFix.SessionSettings("fix.cfg");
var client = new QuickFixClient();
var storeFactory = new QuickFix.FileStoreFactory(settings);
var logFactory = new QuickFix.ScreenLogFactory(settings);
var initiator = new QuickFix.Transport.SocketInitiator(client, storeFactory, settings, logFactory);
initiator.Start();
client.Run();
initiator.Stop();
并替换
public void ToAdmin(Message message, SessionID sessionID) {}
用这个
public void ToAdmin(Message message, SessionID sessionID)
{
if (message.GetType() == typeof(QuickFix.FIX44.Logon))
{
message.SetField(new Username("YOUR_USERNAME"));
message.SetField(new Password("YOUR_PASSWORD"));
}
message.SetField(new QuickFix.Fields.Account("YOUR_ACCOUNT_NUMBER"));
}
FXCM要求每个消息发送的账号(标签1=)都是有效的。如果不存在,也可能会阻止成功登录。
希望这能有所帮助!
这就是我添加密码的方式:
void toAdmin( FIX::Message& message, const FIX::SessionID& sessionID)
{
// put password in the logon message
if (FIX::MsgType_Logon == message.getHeader().getField(FIX::FIELD::MsgType))
{
FIX::Password fixpasswd = ConfigSingleton::getInstance().CurrenexConfig.FIXPassword; //use your std::string password here.
message.getHeader().setField(FIX::Password(fixpasswd)); //also add username here.
}
}
如果你能看到你的用户名和密码,那么这意味着已经可以了。关于例外,我以前也遇到过。对我来说,它来自toApp功能,我将其更改如下,效果良好:
void toApp( FIX::Message& message, const FIX::SessionID& sessionID )
throw( FIX::DoNotSend )
{
try
{
FIX::PossDupFlag possDupFlag;
message.getHeader().getField( possDupFlag );
if ( possDupFlag ) throw FIX::DoNotSend();
}
catch ( FIX::FieldNotFound& e)
{
//std::cout << e.what() << " " << message.toString() << ENDLINE;
}
}
事实上,也不例外。
顺便说一句,如果你没有为某些消息类型定义自己的函数,这些消息将被拒绝。
希望这会有所帮助。
相关文章:
- 密码登录程序将永远循环并显示不正确的结果
- 如何检查cURL是否成功登录?c ++
- 在 Tizen 中登录特定文件?
- 如何在 c++ 中将密码和用户名保存到 .txt 文件中.如果用户尝试登录,我仍然希望能够检索它们
- Win7 C++ - 从以用户身份登录的服务启动可执行文件的问题
- 在主窗口之前显示登录对话框并隐藏主窗口按钮
- 如何使用 libcurl 登录本网站?(C++)
- 如何使用 Apache C 模块登录到文件
- 用户注销/登录后,创建托盘图标时出现罕见错误
- 将正在运行的程序的用户名与登录到Windows的用户名进行比较
- 使用二进制文件的用户名和登录系统
- C++登录面板以查看 cout
- 从C++ Windows 服务中获取当前登录的用户名
- 是否有任何 C 函数或 API 来获取当前登录用户下运行的进程列表
- 不会在登录名中读取C++我的文件
- 尝试制作登录程序
- QT MySql 数据库检查登录名和密码以登录
- 与远程登录客户端协商回声
- 由于密码丢失,QuickFix登录失败
- QuickFIX和MFC:无法使用initiator .logon()函数登录