binance-connector-python icon indicating copy to clipboard operation
binance-connector-python copied to clipboard

`socket.timeout: _ssl.c:1112: The handshake operation timed out` not captured in `except Exception`

Open alverelt opened this issue 1 year ago • 0 comments

This happened once when i instantiated SpotWebsocketStreamClient, it raised that was never captured, i will show the code:

def _load_websocket_client(self):
        stream_url_1 = 'wss://stream.binance.com:9443'
        stream_url_2 = 'wss://stream.binance.com:443'
        c = 0
        max_retries = 4
        while True:
            try:
                if c in [0, 2]:
                    stream_url = stream_url_1
                else:
                    stream_url = stream_url_2

                // some logging

                self.stream_client = SpotWebsocketStreamClient(
                    stream_url=stream_url,
                    on_message=self.message_handler,
                    on_error=self.error_handler,
                    on_close=self.close_handler
                )

                break
            except Exception:
                human_show_and_save({
                    'msg': f'Try {c+1} of {max_retries} failed instatiaing websocket.'
                })

                if c >= max_retries:
                    raise

                c += 1 

It should have been captured in the except Exception but it didn't.

Environment

  • binance-connector==3.3.0
  • Python version: 3.9
  • Operating system: Ubuntu 22.04.3 LTS

alverelt avatar Nov 27 '23 21:11 alverelt