首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何获得到Kucoin Exchange的websocket连接

如何获得到Kucoin Exchange的websocket连接
EN

Stack Overflow用户
提问于 2022-07-21 14:29:56
回答 1查看 383关注 0票数 0

如何获得到Kucoin Exchange的websocket连接?我正在尝试这个密码:

代码语言:javascript
复制
import os
import time, hashlib, requests, base64, hmac, json, websocket, uuid    
now = str(int(time.time() * 1000))
token = "my token"
SOCKET = f'wss://push1-v2.kucoin.net/endpoint?token={token}&connectId={now}'
params = {"type": "subscribe", "topic": "/market/ticker:BTC-USDT", "response": True}

def on_open(ws):
    print('Opened Connection')
    ws.send(json.dumps(params))

def on_close(ws):
    print('Closed Connection')

def on_ping(ws, message):
    pass

def on_pong(ws, message):
    pass

def on_message(ws, message):
    print(message)

def on_error(ws, err):
  print("Got a an error: ", err)

if __name__ == "__main__":
    ws = websocket.WebSocketApp(SOCKET, on_open = on_open, on_close = on_close, on_message = on_message,on_error=on_error, on_ping=on_ping, on_pong=on_pong)
    ws.run_forever(ping_interval=10, ping_timeout=5)

但是我收到消息: Errno 11001 getaddrinfo失败了,也许我使用了错误的端点?我必须使用哪个端点?

EN

回答 1

Stack Overflow用户

发布于 2022-08-10 19:50:32

只需将此项目(push1-v2.kucoin.net)更改为(ws-api.kucoin.com)

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73068029

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档