关于 python:使用 stunnel 建立与 DUKASCOPY 的连接 | 珊瑚贝

Establishing a connection to DUKASCOPY using stunnel


在通过 FIX4.4 协议使用 stunnel 和 quickfix python 与我的经纪人 DUKASCOPY 建立连接时寻求帮助。

这是我的 stunnel 配置:

1
2
3
4
5
6
client = yes
cert = /etc/stunnel/stunnel.pem

[OKSERVER]
accept = 9443
connect = demo-api.dukascopy.com:10443

我的快速修复 cfg 文件:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[DEFAULT]
ConnectionType=initiator
LogonTimeout=30
ReconnectInterval=30
ResetOnLogon=Y
FileLogPath=./Logs/

[SESSION]
BeginString=FIX.4.4
SenderCompID=SENDER_ID # replaced with anonymous value for this post
TargetCompID=TARGET_ID # replaced with anonymous value for this post
StartTime=00:00:00
EndTime=00:00:00
HeartBtInt=30
CheckLatency=N
MaxLatency=240
SocketConnectPort=10443
SocketConnectHost=demo-api.dukascopy.com
UseDataDictionary=Y
DataDictionary=/home/jaspal/qfsample/quickfix/spec/FIX44.xml
FileStorePath=./Sessions/

当我尝试登录时,我得到:

1
2
3
4
5
2018100222:26:23.972817000 : Created session
2018100222:26:23.978505000 : Connecting to demo-api.dukascopy.com on port 10443 (Source :0)
2018100222:26:24.023770000 : Initiated logon request
2018100222:26:24.065703000 : Socket Error: Connection reset by peer.
2018100222:26:24.065799000 : Disconnecting

我可以确认我正在监听传入端口:

1
2
~/qfsample/quickfix-python-sample$ netstat -an | grep 9443
    tcp        0      0 0.0.0.0:9443            0.0.0.0:*               LISTEN

我还在路由器上配置了 9443 端口转发到客户端机器。

以下是我从应用程序收到的消息:

1
2
onCreate(self=<__main__.Application; proxy of <Swig Object of type ‘FIX::Application *’ at 0x7f87db719030> >, sessionID=<quickfix.SessionID; proxy of <Swig Object of type ‘FIX::SessionID *’ at 0x7f87db6674e0> >)
toAdmin(self=<__main__.Application; proxy of <Swig Object of type ‘FIX::Application *’ at 0x7f87db719030> >, sessionID=<quickfix.Message; proxy of <Swig Object of type ‘FIX::Message *’ at 0x7f87db667e70> >, message=<quickfix.SessionID; proxy of <Swig Object of type ‘FIX::SessionID *’ at 0x7f87db667d20> >)

非常欢迎您在此处找到问题的任何帮助!

  • 还可以考虑在 stunnel 中使用 verify checkHost CAfile 选项,以检查证书信任链返回到 CA …


好的。所以我想我要么从这个伟大的论坛获得一些帮助,要么自己解决这个问题是不可避免的!在这种情况下是后者!

这是我出错的地方:

当您使用 stunnel 创建隧道时,您必须将目标设置到本地计算机上您在 stunnel 配置中为”接受”创建的端口,而不是代理的地址。现在很明显!这是我的 cfg 文件现在的样子:

1
2
SocketConnectPort=9443
SocketConnectHost=localhost
  • 感谢您发布您的答案。那么,我是否正确地说您将您的发起者指向 stunnel,然后在您的 stunnel 配置中使用 IP 和端口作为交易场所?
  • @p.luck:正确:FIX -> Stunnel -> 交易场所


感谢@Jaspal 发布您的 Q


来源:https://www.codenong.com/52617392/

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_9568.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?