Skip to content

Commit

Permalink
fix trade ws reconnecting error
Browse files Browse the repository at this point in the history
  • Loading branch information
51bitquant committed Jul 25, 2022
1 parent b58ea07 commit 3e6715f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion howtrader/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.2.3"
__version__ = "3.2.4"
6 changes: 6 additions & 0 deletions howtrader/api/websocket/websocket_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ def on_error(
except Exception:
traceback.print_exc()

def on_exit_loop(self):
pass

def exception_detail(
self,
exception_type: type,
Expand Down Expand Up @@ -193,6 +196,9 @@ async def _run(self):
except Exception:
et, ev, tb = sys.exc_info()
self.on_error(et, ev, tb)
break

self.on_exit_loop()

def _record_last_sent_text(self, text: str):
"""record the last send text for debugging"""
Expand Down
3 changes: 3 additions & 0 deletions howtrader/gateway/binance/binance_inverse_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,9 @@ def on_packet(self, packet: dict) -> None:
elif packet['e'] == 'listenKeyExpired':
self.gateway.rest_api.start_user_stream()

def on_exit_loop(self):
self.gateway.rest_api.start_user_stream()

def on_account(self, packet: dict) -> None:
"""account data update"""
for acc_data in packet["a"]["B"]:
Expand Down
3 changes: 3 additions & 0 deletions howtrader/gateway/binance/binance_spot_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,9 @@ def on_packet(self, packet: dict) -> None:
elif packet['e'] == 'listenKeyExpired':
self.gateway.rest_api.start_user_stream()

def on_exit_loop(self):
self.gateway.rest_api.start_user_stream()

def on_account(self, packet: dict) -> None:
"""account data update"""
for d in packet["B"]:
Expand Down
3 changes: 3 additions & 0 deletions howtrader/gateway/binance/binance_usdt_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,9 @@ def on_packet(self, packet: dict) -> None:
elif packet['e'] == 'listenKeyExpired':
self.gateway.rest_api.start_user_stream()

def on_exit_loop(self):
self.gateway.rest_api.start_user_stream()

def on_account(self, packet: dict) -> None:
"""account data update"""
for acc_data in packet["a"]["B"]:
Expand Down

0 comments on commit 3e6715f

Please sign in to comment.