From 847f7631fe3ce4fc2d469bb321bb95108355f2fc Mon Sep 17 00:00:00 2001 From: Denis Medvedev Date: Mon, 9 Sep 2024 20:41:08 +0300 Subject: [PATCH] Fix # 960 --- binance/client.py | 4 ++-- binance/streams.py | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/binance/client.py b/binance/client.py index 7d0d3239..1477f1f6 100755 --- a/binance/client.py +++ b/binance/client.py @@ -2696,7 +2696,7 @@ def get_trade_fee(self, **params): ] """ - if self.tld == 'us' + if self.tld == 'us': endpoint = 'asset/query/trading-fee' else: endpoint = 'asset/tradeFee' @@ -9263,7 +9263,7 @@ async def query_universal_transfer_history(self, **params): query_universal_transfer_history.__doc__ = Client.query_universal_transfer_history.__doc__ async def get_trade_fee(self, **params): - if self.tld == 'us' + if self.tld == 'us': endpoint = 'asset/query/trading-fee' else: endpoint = 'asset/tradeFee' diff --git a/binance/streams.py b/binance/streams.py index 37f8c204..a2bcd13e 100755 --- a/binance/streams.py +++ b/binance/streams.py @@ -209,9 +209,12 @@ def _get_reconnect_wait(self, attempts: int) -> int: return round(random() * min(self.MAX_RECONNECT_SECONDS, expo - 1) + 1) async def before_reconnect(self): - if self.ws and self._conn: - await self._conn.__aexit__(None, None, None) + if self.ws: self.ws = None + + if self._conn and hasattr(self._conn, 'protocol'): + await self._conn.__aexit__(None, None, None) + self._reconnects += 1 def _no_message_received_reconnect(self):