请问okex的websocket怎么请求呀?

Author: 金十量化, Created: 2021-07-05 14:18:21, Updated:

img 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接口中的产品频道,总是超时,有谁能给个正确的代码么


More

小草 需要海外托管者,另外不要使用调试工具调试wss