aut*_*817 4 c# c++ quickfix fix-protocol quickfixj
我在下面的此链接上使用交易客户应用程序在我的VPS服务器和代理服务器之一之间建立连接。
http://www.quickfixn.org/tutorial/example-applications。
经过一个星期的挣扎,我终于可以轻松地建立与代理服务器的连接。
但是,当我运行交易客户应用程序时,在登录阶段出现以下错误:
Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host
at QuickFix.SocketInitiatorThread.ReadSome(Byte[] buffer, Int32 timeoutMilliseconds)
in ... SoecketInitiatorThread.cs:line 170 ......
at QuickFix.SocketInitiatorThread.Read() in ... SoecketInitiatorThread.cs:line 80
......
Run Code Online (Sandbox Code Playgroud)
贸易客户应用程序一直在重复登录尝试,但是,它始终仅获得相同的错误消息。
当然,对于像我这样的新手使用此QuickFix / n引擎,我真的无法弄清楚出了什么问题。我可以想到的一个可能的调查领域是,我对隧道程序(https://www.stunnel.org)也很陌生,因此我的隧道证书可能无效。我只是按照网站上的指示使用代理的ip地址配置pem证书,但是我不确定它的用途是100%。
这是我放在“ stunnel.conf”文件中的内容:
[FIXORDER]
client = yes
accept = external ip of VPS : port eg.(10.160.103.65:22)
connect = broker ip address :port eg.(102.12.124.9:444)
Run Code Online (Sandbox Code Playgroud)
这是来自Stunnel程序的已记录消息的一些记录:
2014.11.26 17:23:44 LOG5[3348]: Connection reset: 0 byte(s) sent to SSL, 0 byte(s) sent to socket
2014.11.26 17:23:48 LOG5[760]: Service [FIXORDER] accepted connection from x.xx.xx.xxx:xx
2014.11.26 17:23:48 LOG5[760]: s_connect: connected xxx.x.xx.xxx:xxx
2014.11.26 17:23:48 LOG5[760]: Service [FIXORDER] connected remote server from x.xx.xxx.xxx:xxx
2014.11.26 17:23:48 LOG3[760]: SSL_connect: Peer suddenly disconnected
2014.11.26 17:23:48 LOG5[760]: Connection reset: 0 byte(s) sent to SSL, 0 byte(s) sent to socket
Run Code Online (Sandbox Code Playgroud)
我使用内置的自我证书应用程序使用上面的“ stunnel.conf”文件构建了证书。
如您所见,对于像我这样的新手来说,这有点复杂,对此问题的任何想法或提示都将不胜感激。
非常感谢。
亲切的问候。
中号
================================================== ================================ 2014年11月27日更新
在这里,我将xapi1492的建议设置为调试详细级别,然后从Stunnel日志文件更新错误日志。
2014.11.27 01:10:46 LOG7[944]: Service [FIXORDER] started
2014.11.27 01:10:46 LOG5[944]: Service [FIXORDER] accepted connection from x.xxx.xxx.xxx:3667
2014.11.27 01:10:46 LOG6[944]: s_connect: connecting xx.x.xx.xx:9002
2014.11.27 01:10:46 LOG7[944]: s_connect: s_poll_wait xx.x.xx.102:9002: waiting 10 seconds
2014.11.27 01:10:46 LOG5[944]: s_connect: connected xx.x.xx.xx:9002
2014.11.27 01:10:46 LOG5[944]: Service [FIXORDER] connected remote server from x.xxx.xxx.xxx:3668
2014.11.27 01:10:46 LOG7[944]: Remote socket (FD=392) initialized
2014.11.27 01:10:46 LOG6[944]: SNI: sending servername: xxx.x.xx.xx
2014.11.27 01:10:46 LOG7[944]: SSL state (connect): before/connect initialization
2014.11.27 01:10:46 LOG7[944]: SSL state (connect): SSLv2/v3 write client hello A
2014.11.27 01:10:46 LOG3[944]: SSL_connect: Peer suddenly disconnected
2014.11.27 01:10:46 LOG5[944]: Connection reset: 0 byte(s) sent to SSL, 0 byte(s) sent to socket
2014.11.27 01:10:46 LOG7[944]: Remote socket (FD=392) closed
2014.11.27 01:10:46 LOG7[944]: Local socket (FD=380) closed
2014.11.27 01:10:46 LOG7[944]: Service [FIXORDER] finished (0 left)
Run Code Online (Sandbox Code Playgroud)
================================================== ================================更新于2014/11/28
仍然很难找到答案,因此我决定为QuickFix客户端应用程序提供配置文件。
[DEFAULT]
ConnectionType=initiator
ReconnectInterval=2
FileStorePath=store
FileLogPath=fixlog
StartTime=00:00:00
EndTime=00:00:00
UseDataDictionary=Y
DataDictionary=FIX44.xml
SocketConnectHost= xxx //my vps ip address
SocketConnectPort= xxx //my vps port //specified on stunnel
ResetOnLogon=Y
ResetOnLogout=Y
ResetOnDisconnect=Y
CheckLatency=N
LogonTimeout=10
# standard config elements
[SESSION]
BeginString=FIX.4.4
SenderCompID= xxx //my ID
Username= xxx //my username
Password= xxx //my password
TargetCompID=FIXORDER
HeartBtInt=30
SocketConnectHost= xxx //my vps ip address
SocketConnectPort= xxx //my vps port //specified on stunnel
DataDictionary=FIX44.xml
Run Code Online (Sandbox Code Playgroud)
================================================== ================================更新于2014/11/28
根据xpa1492的建议,我将Borker的IP地址和端口号放在SocketConnectHost和SocketConnectPort上。这是我从QuickFix Client Application获得的日志消息。似乎已建立初始连接,但登录请求可能以某种方式无效。
<event> connecting to xxx (ip address of broker);
<event> connection succeeded;
<event> session reset: ResetOnLogon;
<event> session reset ResetSetNumFlag;
<outgoing> 8=Fix4.4 ...... ;
<event> initiated logon request;
<incoming> 8=FIX4.4 .....;
<event> received logout request;
<outgoing> 8=FIX4.4 .....;
<event> sending logout response;
Run Code Online (Sandbox Code Playgroud)
代理发送注销请求时来自代理的传入消息的详细信息。
<incoming> 8=FIX4.4 9=63 35=5 34=1 49=FIXORDER 52=20141128-02:09:00.495 56=TargetCompID(from acceptor standing point of view=SenderID for me) 10=171
Run Code Online (Sandbox Code Playgroud)
当FIX服务器不喜欢您的第一条消息(总是登录消息)时,断开连接是很常见的。根据您得到的错误,这正是发生的情况-连接到服务器,发送登录消息,然后服务器断开连接。
解决此问题的正确方法是与另一端的技术支持联系,并询问他们为什么断开连接。
如果这不可行,您将需要尝试做错什么。以我的经验,问题通常是序列号不匹配(标签34)。大多数服务器将保留您发送的最后一个序列号(例如1),并且在断开连接后,您希望发送带有下一个编号的登录消息(在本示例中为2)。尝试从1开始,并在重新连接之间增加seq编号。
另一个可能的问题是错误的CompID(发件人或Targer)。
更新(隧道和SSL证书设置):
服务器可能会断开连接,因为您未通过SSL连接... stunnel.conf文件需要如下所示:
; Enable debug (7 is the most verbose output)
debug = 7
output = stunnel.log
[FIXORDER]
client = yes
accept = 127.0.0.1:[port number your client connects to]
connect = [fix server ip]:[fix server port]
cert = xxx_cert.pem
key = xxx_key.pem
Run Code Online (Sandbox Code Playgroud)
请注意,accept可以是127.0.0.1或VPS服务器的IP,但是首选是127.0.0.1。然后,您的Fix客户端也可以只连接到127.0.0.1(在其中sTunnel进行监听)。
| 归档时间: |
|
| 查看次数: |
2980 次 |
| 最近记录: |