Type/to search
0
Follow
0
Followers
¿Cómo solicito el websocket de OKEx?
Help
Created 2021-07-05 14:18:21  
 1
 1542

img
function main(){
var param = {
"op": "subscribe",
"args": [
{
"channel" : "instruments",
"instType": "FUTURES"
}
]
}
// Especificar cuando se llama a la función Dialreconnect=trueEs decir, en modo de reconexión, especificarpayloadEs decir, los mensajes enviados en el momento de la reconexión. Una vez que la conexión del websocket se corta, se reconecta automáticamente y envía mensajes automáticamente.
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 (("Enviado por:ping", "#FF0000")
}
LogStatus: "Hora actual: el jueves", _D())
Sleep(1000)
}
ws.close()
}
}

Por ejemplo, el canal de productos en la interfaz websocket de OKEX que solicita el código de arriba, siempre está fuera de tiempo, ¿alguien puede darme el código correcto?

Related Recommendations
Comment
All comments (1)

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

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