我正在使用 fxcmpy 的 REST api 连接到我的 fxcmpy 帐户。自从升级到 1.2.6 版后,当我意外从服务器断开连接时,我遇到了重新连接问题。
我通过命令检测到断开连接
api.socket.on('disconnect',disconnect)
其中 disconnect 是我重新连接的回调函数:
def disconnect():
FLAG=False
while not FLAG:
try :
api=fxcmpy.fxcmpy(access_token=API_ACCESS_TOKEN,log_level='error',server='demo')
api.subscribe_market_data(symbol,(automated_strategy,))
FLAG=True
except:
print('be patient')
time.sleep(60)
FLAG=False
由于新版本我得到一个“服务器错误:无法连接到 FXCM 服务器”。或“数据包队列为空,正在中止”消息。
如果我重新启动我的 python 控制台,我可以重新启动我的脚本,直到下一次断开连接。我在 Windows 10、Raspbian 和 android 上试过这个:在所有情况下都是同样的问题。
我已经将 python-socketio 和 python-engineio 都更新到了它们的最新版本:没有变化。
当我遇到断开连接问题时,我正在寻找一种重新启动客户端的方法。有人有同样的问题/解决它的线索吗?
谢谢