WebSocket中的binance recv()已挂起

2024-05-13 07:10:42 发布

您现在位置:Python中文网/ 问答频道 /正文

我有以下代码:

client = await AsyncClient.create(api_key=api_key, api_secret=api_secret)
bm = BinanceSocketManager(client, user_timeout=60)
tst = bm.multiplex_socket(['btcusdt@ticker'])
async with tst as tscmt:
while True:
     print('comes to this point')
     res = await tscmt.recv()
     print("waiting and waiting, don't come to this point anymore after x hours of working.")
     __self__.doSomeStuff(res)
     time.sleep(10)

基本上是从以下位置复制和粘贴:https://python-binance.readthedocs.io/en/latest/websockets.html

我不知道为什么,但是recv()有时在5小时后挂起,有时在2天后挂起

我设置了一个user_timeout=60,但这不起作用

有人有主意吗


Tags: tokeyclientapisecrettimeoutresawait