请问websocket的reconnect是自动的吗,需要业务端额外实现断线重连吗
mostcute opened this issue · 7 comments
mostcute commented
请问websocket的reconnect是自动的吗,需要业务端额外实现断线重连吗
caronwang commented
自动的
mostcute commented
根据日志似乎没有自动reconnect
ERROR:asyncio:Task exception was never retrieved
future: <Task finished name='Task-6' coro=<WsPublicAsync.consume() done, defined at /root/anaconda3/lib/python3.9/site-packages/okx/websocket/WsPublicAsync.py:22> exception=ConnectionClosedError(None, Close(code=1011, reason='keepalive ping timeout'), None)>
Traceback (most recent call last):
File "/root/anaconda3/lib/python3.9/site-packages/websockets/legacy/protocol.py", line 979, in transfer_data
await asyncio.shield(self._put_message_waiter)
asyncio.exceptions.CancelledError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/root/anaconda3/lib/python3.9/site-packages/okx/websocket/WsPublicAsync.py", line 23, in consume
async for message in self.websocket:
File "/root/anaconda3/lib/python3.9/site-packages/websockets/legacy/protocol.py", line 497, in __aiter__
yield await self.recv()
File "/root/anaconda3/lib/python3.9/site-packages/websockets/legacy/protocol.py", line 568, in recv
await self.ensure_open()
File "/root/anaconda3/lib/python3.9/site-packages/websockets/legacy/protocol.py", line 953, in ensure_open
raise self.connection_closed_exc()
websockets.exceptions.ConnectionClosedError: sent 1011 (unexpected error) keepalive ping timeout; no close frame received
mostcute commented
caronwang commented
老版本的websocket方法是有自动重连机制的,你用的这个是新版本的确实没有自动重连
mostcute commented
@caronwang 感觉很重要啊自动重连,不然无法保证业务连续运行了,有计划更新这个功能吗
caronwang commented
这个自己捕捉一下异常实现重连并不是一件困难的事情吧。断线重连这个功能,隔多久重连,重连几次等等用户可以保留更多自由度。
Tarryhao commented
老版本的websocket方法是有自动重连机制的,你用的这个是新版本的确实没有自动重连
老版本是指哪个版本,我也遇到这个问题了,不知道这个异常怎么捕获