avatar of 金十量化 金十量化
关注 私信
0
关注
0
关注者

请问okex的websocket怎么请求呀?

创建于: 2021-07-05 14:18:21, 更新于:
comments   1
hits   1053

请问okex的websocket怎么请求呀? function main(){ var param = { “op”: “subscribe”,
“args”: [
{
“channel” : “instruments”, “instType”: “FUTURES” } ] } // 在调用Dial函数时,指定reconnect=true即设置为重连模式,指定payload即为重连时发送的消息。在websocket连接断开后,会自动重连,自动发送消息。 var ws = Dial(“wss://wsaws.okex.com:8443/ws/v5/public|compress=gzip_raw&mode=recv&reconnect=true&”+ JSON.stringify(param)) if(ws){ ws.write(JSON.stringify(param)) var pingCyc = 1000 * 20 var lastPingTime = new Date().getTime() while(1){ var nowTime = new Date().getTime() var ret = ws.read() Log(“ret:”, ret) if(nowTime - lastPingTime > pingCyc){ var retPing = ws.write(“ping”) lastPingTime = nowTime Log(“发送 :ping”, “#FF0000”) } LogStatus(“当前时间:”, _D()) Sleep(1000) } ws.close() } }

如题,用以上代码请求okex的websocket接口中的产品频道,总是超时,有谁能给个正确的代码么

相关推荐
全部留言
avatar of 小草
小草
需要海外托管者,另外不要使用调试工具调试wss
2021-07-05 14:28:55