Open dadastake opened 1 year ago
you should sent ping instead pong
but i send ping and get pong from dydx. still have1006 error, sometimes it shows another error called 'v3_accountsTimestamp must be within 30 seconds of the server time' I am not sure which part cause this problem
Hello everyone,
I realise that this might not be exactly up for discussion here, but I will still share it since you've also built https://github.com/dydxprotocol/dydx-v3-python/blob/master/examples/websockets.py
I am building our own implementation from scratch of a websocket client. I can successfully send subscribe and unsubscribe messages for the orderbook and last trades feeds. Additionally I send a ping every 10 seconds and successfully receive a pong message back.
However after about 2 minutes of connection, the connection dies and when
websocket.recv()
is called, I receive the following error:websockets.exceptions.ConnectionClosedError: code = 1006 (connection closed abnormally [internal]), no reason
My connection is established as:
From what I can see, on your documentation here (https://github.com/dydxprotocol/dydx-v3-python/blob/master/examples/websockets.py) there is no handling of ping messages from the server.
Addtionally, from cursory review of similar issues online, my problem seems to happen on lack of pings from the client, but I'm sending those and receiving PONGs back.
I am also not receiving any ping messages from the server as https://dydxprotocol.github.io/v3-teacher/?json#v3-websocket-api mentions.
I have tried to send unsolicited pong messages to the server, but that doesn't work either, as they are not accepted on the channel receiving the following response:
{'type': 'error', 'message': 'Invalid message type: pong', 'connection_id': 'xxxx-xxxx-xxx', 'message_id': 2}
Finally, after some time the connection becomes stale in one of two states:
I handle these cases and reconnect. However, I'm going for as much uptime as possible, so I'm trying to understand why my client gets disconnected. Especially since I have tested and you can have a lot of subscriptions (>50) to the same channel from the same IP (as long as your respect the rate limiting requirements).
I'm using Python 3.9.
Do you, maybe, have any help?