Binance Private Chnannel listenKeyExpired, auto reconnection
xiandong79 opened this issue · 6 comments
I [2021-06-25 13:48:09,570] [.swap_account_update] swap_account_update: {'stream': 'njbKoDaXfnrYsLgychLJ4B8cCfdFHxbBNxHbm9sqgrrNizGB2b1k4lL3Ud7BbaDh', 'data': {'e': 'listenKeyExpired', 'E': 1624628889565}}
I [2021-06-25 13:48:09,584] [.swap_account_update] swap_account_update: {'stream': 'njbKoDaXfnrYsLgychLJ4B8cCfdFHxbBNxHbm9sqgrrNizGB2b1k4lL3Ud7BbaDh', 'data': {'e': 'listenKeyExpired', 'E': 1624628889565}}
Current code, does not auto refresh the listenKey
or auto-reconnect.
Disaster happens for live trading
@xiandong79 How long did it take to receive the listenKeyExpired message? I have tested all account websockets and had them opened for several hours without issues. It makes sense to refresh the listenKey once it expires but first I need to manage to simulate the scenario.
Alright, so no expiration message is sent for spot and margin account websocket, it is sent only for futures.
There are two options:
1/ refresh the listenKey as soon as listenKeyExpired is received
2/ refresh the listenKey proactively every ±30mins
Option 2/ is preferable since 1/ can lead to a situation where some messages might get lost between expiration and refresh of the listenKey.
@xiandong79, the fix is included in #66. Do you want to give it a try before I officially release it?
Yes, I face the case for COIN future Account Channel. like 1 hour after running the strategies.
2/ refresh the listenKey proactively every ±30mins
is better.
Delivered in 5.1.5
.