Type/to search
0
Follow
0
Followers
Les contrats hbdm et ok utilisent websocket en même temps, mais huobi envoie pong mais aucune réponse
FAQ
Created 2019-03-21 00:35:45  Updated 2019-03-21 11:26:42
 8
 3648

Le code est le suivant, huobi après environ cinq ou six secondes, il reçoit le ping du serveur, puis je lance un ping, mais c'est comme si le serveur ne recevait pas de ping, il continue de m'envoyer un ping, demandez à Dieu de dire que c'est pour read plus-1, mais plus ou pas.

function main() { var ws_hbdm = Dial("wss://www.hbdm.com/ws?compress=true|compress=gzip&mode=recv") var ws_ok= Dial("wss://real.okex.com:10440/ws/v1?compress=true|compress=gzip_raw&mode=recv") var pingCyc = 1000 * 120 var lastPingTime = new Date().getTime() if(ws_hbdm && ws_ok){ ws_hbdm.write('{"sub": "market.EOS_CW.depth.step6","id": "id2"}') ws_ok.write("{'event':'addChannel','channel':'ok_sub_futureusd_eos_depth_this_week_5'}") while(1){ //读取huobi数据 var ret = ws_hbdm.read(-1) if(ret){ var ret1=JSON.parse(ret) if("tick" in ret1){ Log("huobi",ret1.tick) }else if("ping" in ret1){ ws_hbdm.write('{"pong":'+parseInt(ret1.ping)+'}') Log("pong") } } //读取ok数据 var nowTime = new Date().getTime() var ret2 = ws_ok.read(-1) if(ret2){ if(nowTime - lastPingTime > pingCyc){ ws_ok.write("{'event':'ping'}") lastPingTime = nowTime } var ret3=JSON.parse(ret2) if(ret3.length>0){ if("data" in ret3[0]){ Log("ok",ret3[0].data) } } } } //ws_hbdm.close() } }

Le journal est le suivant: (J'ai toujours envoyé un message à Huobi, et il n'a pas répondu)
Je suis désolée, mais je ne peux pas vous aider.[[3.687,18。。。。
Je ne sais pas si c'est vrai, mais j'aimerais bien savoir.[[3.687,1684。。。。
2019-03-21 00:30:24 Pong de l'information
Je ne sais pas si c'est une bonne idée, mais je pense que c'est une bonne idée.[[3.687,1684。。。。
Je ne sais pas si c'est une bonne idée, mais je pense que c'est une bonne idée.[[3.687,1711,4640。。。

API de la pièce
https://github.com/huobiapi/API_Docs/wiki/WS_request

Related Recommendations
Comment
All comments (8)

    看看是不是服务器位置的原因,另外更新一下托管者

    7 years ago

    img 复制你的代码试了下,没问题

    7 years ago

    谢谢! 更新了托管者,好了

    7 years ago

    额,你这托管者太老了,ws解压各种模式都是后来加的

    7 years ago

    有些交易所服务器每隔一段时间就发一个ping检查链接

    7 years ago

    是的,我收到Ping的检查之后,马上回复pong,xxx.read() 这样读到之后返回pong是可以的,xxx.read(-1)这样就不可以了,不知道原因

    7 years ago

    还是没明白你有什么问题

    7 years ago

    如代码,我想同时获取OK和火币的行情数据,OK可以一直收到行情数据,但火币过了5秒之后就收不到了(我也回应了ping),所以想让帮忙看看代码,找找原因,我找了两天了

    7 years ago
  • 1
Forums
PINE Language
Get the app
iPhone Download
© 2015 - ∞ INVENTOR PTE LTD (SG)