-
It seems bybit requires user to send custom ping in Its offical sdk using class Listener(WSListener):
def __init__(self, logger, specific_ping_msg: bytes = None):
self._log = logger
self.msg_queue = asyncio.Queue()
self._specific_ping_msg = specific_ping_msg
def send_user_specific_ping(self, transport: WSTransport):
if self._specific_ping_msg:
transport.send(WSMsgType.TEXT, self._specific_ping_msg)
else:
transport.send_ping()
def on_ws_connected(self, transport: WSTransport):
self._log.info("Connected to Websocket...")
def on_ws_disconnected(self, transport: WSTransport):
self._log.info("Disconnected from Websocket.")
def on_ws_frame(self, transport: WSTransport, frame: WSFrame):
try:
if frame.msg_type == WSMsgType.PING:
transport.send_pong(
frame.get_payload_as_bytes()
) # if enabled auto pong, we don't need to send pong manually
return
# msg = orjson.loads(frame.get_payload_as_bytes())
self.msg_queue.put_nowait(
frame.get_payload_as_bytes()
) # I think we should decode the frame in the handler
except Exception as e:
self._log.error(f"Error processing message: {str(e)}") However, If I send
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Beta Was this translation helpful? Give feedback.
-
It seems that picows library initiating disconnect because you didn't let picows know that you have received user specific pong. If you redefine ping messages by overriding WSListener.send_user_specific_ping, you should also redefine expected pong replies by redefining either WSListener.is_user_specific_pong or by calling transport.notify_user_specific_pong_received() from on_ws_frame. Check the guide on auto ping feature. It explains that. Also picows logs that it has not received user specific pong within required time and that's why it has initiated disconnect. You should be able to see that in the log |
Beta Was this translation helpful? Give feedback.
It seems that picows library initiating disconnect because you didn't let picows know that you have received user specific pong.
If you redefine ping messages by overriding WSListener.send_user_specific_ping, you should also redefine expected pong replies by redefining either WSListener.is_user_specific_pong or by calling transport.notify_user_specific_pong_received() from on_ws_frame.
Check the guide on auto ping feature. It explains that.
https://picows.readthedocs.io/en/stable/guides.html#auto-ping
Also picows logs that it has not received user specific pong within required time and that's why it has initiated disconnect. You should be able to see that in the log