Keep getting SSL errors (with some DNS) using binance connector library

Hey I recently posted about another minor issue I was experiencing using my own code and was pointed towards the official binance github which I honestly wish I had discovered earlier as I would not have spent so much time developing my own code, and its a lot cleaner and more elegant than mine came out to be.
Anyway I tried to test it against mine to see if my implementation was the issue however no matter what I do I cant get rid of these errors:

 WARNING:root:WebSocket connection closed: connection was closed uncleanly (SSL error: certificate verify failed (in tls_process_server_certificate)), code: 1006, clean: False, reason: connection was closed uncleanly (SSL error: certificate verify failed (in tls_process_server_certificate)) 
ERROR:root:Lost connection to Server. Reason: [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionDone'>: Connection was closed cleanly. ]. 
Retrying: 1 .... repeat the previosu message ...

I don’t get these issues when I use my code which uses the standard python requests library for REST requests and the websockets-client library for handling sockets. However when trying to use binance-connector on some code from binance-toolbox-python I keep getting these errors and no matter where I search or what I do I cant seem to get past them. After searching around and googling I went so far as to uninstall anaconda, remove any left over files including my previous environments, reinstall anaconda and all necessary packages and previous environments and still nothing.

Has anyone else had this issue before? Or can anyone point me in the right direction? I’ve spent the last 2 days pulling my hair out over this and it’s so weird because my code doesn’t experience this issue so I don’t know what it could be. Any help is greatly appreciated.

Same here. It’s incredibly frustrating…

it’s a known issue on windows caused by pyOpenSSL, please check if this helps.

So I noticed that and I tried bnbusdt, BNBUSDT, btcusdt, BTCUSDT, ethusdt, ETHUSDT and I know the scripts makes everything lowercase but based off of the error and not being able to get anything to work I decided to start trying uppercase. How could I get the raw request? I have no experience using these libraries and quite frankly this experience has led me with a bad taste regarding them so is there a quick way I can get that? And unfortunately that just seems to be half of the first of two problems, the other being opening a websocket. Also I’m not creating the request I’m using github/binance-exchnage/binance-toolbox-python/manage_local_order_book.py to create everything and using
symbol = "bnbusdt" or one of the various ones I mentioned before ,
base_url = 'https://api.binance.com' ,
stream_url = 'wss://stream.binance.com:9443'
and have also tried using
base_url = 'https://testnet.binance.vision'
stream_url = 'wss://testnet.binance.vision/ws'
I have tried everything I could think of. I get the same error on a arch linux VM so I have no idea what is wrong or why when my script has no issues with SSL or requesting what-so-ever.
If you could give me some insight I would really appreciate it.

Ok so I tried to run it on Windows subsystem for linux and that didn’t work either. I’m about to spin up a virtual machine to try that, but at this point I have tried so much and am beginning to wonder why an official library simply doesn’t work, or is based on libraries that have very clear issues on windows that cause the library to not work without stating that it wont work on windows (or only work on certain operating systems).

By the way the error I get when running on WSL (windows subsystem for linux):

INFO:root:Connection with URL: wss://stream.binance.com:9443/ws
INFO:root:Start to connect....
INFO:root:Server connected
INFO:root:Sending message to Server: b'{"method": "SUBSCRIBE", "params": ["btcusdt@depth@1000ms"], "id": 1}'
INFO:root:Out of sync, re-syncing...
Unhandled Error
Traceback (most recent call last):
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/python/log.py", line 101, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/python/log.py", line 85, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/python/context.py", line 118, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/python/context.py", line 83, in callWithContext
    return func(*args, **kw)
--- <exception caught here> ---
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/internet/posixbase.py", line 687, in _doReadOrWrite
    why = selectable.doRead()
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/internet/tcp.py", line 246, in doRead
    return self._dataReceived(data)
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/internet/tcp.py", line 251, in _dataReceived
    rval = self.protocol.dataReceived(data)
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/protocols/tls.py", line 324, in dataReceived
    self._flushReceiveBIO()
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/protocols/tls.py", line 290, in _flushReceiveBIO
    ProtocolWrapper.dataReceived(self, bytes)
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/protocols/policies.py", line 107, in dataReceived
    self.wrappedProtocol.dataReceived(data)
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/twisted/websocket.py", line 290, in dataReceived
    self._dataReceived(data)
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py", line 1207, in _dataReceived
    self.consumeData()
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py", line 1219, in consumeData
    while self.processData() and self.state != WebSocketProtocol.STATE_CLOSED:
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py", line 1579, in processData
    fr = self.onFrameEnd()
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py", line 1704, in onFrameEnd
    self._onMessageEnd()
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/twisted/websocket.py", line 318, in _onMessageEnd
    self.onMessageEnd()
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py", line 628, in onMessageEnd
    self._onMessage(payload, self.message_is_binary)
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/twisted/websocket.py", line 321, in _onMessage
    self.onMessage(payload, isBinary)
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/websocket/binance_client_protocol.py", line 30, in onMessage
    self.factory.callback(payload_obj)
  File "manage_local_order_book.py", line 113, in message_handler
    order_book = get_snapshot()
  File "manage_local_order_book.py", line 44, in get_snapshot
    return client.depth(symbol, limit=1000)
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/spot/market.py", line 62, in depth
    return self.query("/api/v3/depth", params)
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/api.py", line 67, in query
    return self.send_request("GET", url_path, payload=payload)
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/api.py", line 116, in send_request
    self._handle_exception(response)
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/api.py", line 169, in _handle_exception
    raise ClientError(status_code, err["code"], err["msg"], response.headers)
binance.error.ClientError: (400, -1100, "Illegal characters found in parameter 'symbol'; legal range is '^[A-Z0-9-_.]{1,20}$'.", {'Content-Type': 'application/json;charset=UTF-8', 'Content-Length': '108', 'Connection': 'keep-alive', 'Date': 'Sat, 17 Jul 2021 22:12:34 GMT', 'Server': 'nginx', 'x-mbx-uuid': '3ef51bc8-1a87-4182-90ca-a0abd1c3fc46', 'x-mbx-used-weight': '10', 'x-mbx-used-weight-1m': '10', 'Strict-Transport-Security': 'max-age=31536000; includeSubdomains', 'X-Frame-Options': 'SAMEORIGIN', 'X-Xss-Protection': '1; mode=block', 'X-Content-Type-Options': 'nosniff', 'Content-Security-Policy': "default-src 'self'", 'X-Content-Security-Policy': "default-src 'self'", 'X-WebKit-CSP': "default-src 'self'", 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'X-Cache': 'Error from cloudfront', 'Via': '1.1 76f9985b0c929a023355db8e462592f0.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'MIA3-C2', 'X-Amz-Cf-Id': '6f5P9LxLM5k4loBTAbXeCa_9Ir7c-KunLm3ne63wzNyIf88dJ3uPVA=='})

WARNING:root:WebSocket connection closed: connection was closed uncleanly (peer dropped the TCP connection without previous WebSocket closing handshake), code: 1006, clean: False, reason: connection was closed uncleanly (peer dropped the TCP connection without previous WebSocket closing handshake)
ERROR:root:Lost connection to Server. Reason: [Failure instance: Traceback: <class 'binance.error.ClientError'>: (400, -1100, "Illegal characters found in parameter 
'symbol'; legal range is '^[A-Z0-9-_.]{1,20}$'.", {'Content-Type': 'application/json;charset=UTF-8', 'Content-Length': '108', 'Connection': 'keep-alive', 'Date': 'Sat, 17 Jul 2021 22:12:34 GMT', 'Server': 'nginx', 'x-mbx-uuid': '3ef51bc8-1a87-4182-90ca-a0abd1c3fc46', 'x-mbx-used-weight': '10', 'x-mbx-used-weight-1m': '10', 'Strict-Transport-Security': 'max-age=31536000; includeSubdomains', 'X-Frame-Options': 'SAMEORIGIN', 'X-Xss-Protection': '1; mode=block', 'X-Content-Type-Options': 'nosniff', 'Content-Security-Policy': "default-src 'self'", 'X-Content-Security-Policy': "default-src 'self'", 'X-WebKit-CSP': "default-src 'self'", 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'X-Cache': 'Error from cloudfront', 'Via': '1.1 76f9985b0c929a023355db8e462592f0.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'MIA3-C2', 'X-Amz-Cf-Id': '6f5P9LxLM5k4loBTAbXeCa_9Ir7c-KunLm3ne63wzNyIf88dJ3uPVA=='})
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/python/log.py:85:callWithContext
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/python/context.py:118:callWithContext
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/python/context.py:83:callWithContext
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/internet/posixbase.py:700:_doReadOrWrite
--- <exception caught here> ---
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/internet/posixbase.py:687:_doReadOrWrite
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/internet/tcp.py:246:doRead
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/internet/tcp.py:251:_dataReceived
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/protocols/tls.py:324:dataReceived
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/protocols/tls.py:290:_flushReceiveBIO
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/protocols/policies.py:107:dataReceived
/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/twisted/websocket.py:290:dataReceived
/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py:1207:_dataReceived
/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py:1219:consumeData
/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py:1579:processData
/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py:1704:onFrameEnd
/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/twisted/websocket.py:318:_onMessageEnd
/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py:628:onMessageEnd
/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/twisted/websocket.py:321:_onMessage
/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/websocket/binance_client_protocol.py:30:onMessage
manage_local_order_book.py:113:message_handler
manage_local_order_book.py:44:get_snapshot
/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/spot/market.py:62:depth
/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/api.py:67:query
/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/api.py:116:send_request
/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/api.py:169:_handle_exception
]. Retrying: 1
INFO:root:Start to connect....
INFO:root:Server connected
INFO:root:Sending message to Server: b'{"method": "SUBSCRIBE", "params": ["btcusdt@depth@1000ms"], "id": 1}'
INFO:root:Out of sync, re-syncing...
Unhandled Error
Traceback (most recent call last):
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/python/log.py", line 101, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/python/log.py", line 85, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/python/context.py", line 118, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/python/context.py", line 83, in callWithContext
    return func(*args, **kw)
--- <exception caught here> ---
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/internet/posixbase.py", line 687, in _doReadOrWrite
    why = selectable.doRead()
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/internet/tcp.py", line 246, in doRead
    return self._dataReceived(data)
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/internet/tcp.py", line 251, in _dataReceived
    rval = self.protocol.dataReceived(data)
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/protocols/tls.py", line 324, in dataReceived
    self._flushReceiveBIO()
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/protocols/tls.py", line 290, in _flushReceiveBIO
    ProtocolWrapper.dataReceived(self, bytes)
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/protocols/policies.py", line 107, in dataReceived
    self.wrappedProtocol.dataReceived(data)
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/twisted/websocket.py", line 290, in dataReceived
    self._dataReceived(data)
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py", line 1207, in _dataReceived
    self.consumeData()
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py", line 1219, in consumeData
    while self.processData() and self.state != WebSocketProtocol.STATE_CLOSED:
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py", line 1579, in processData
    fr = self.onFrameEnd()
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py", line 1704, in onFrameEnd
    self._onMessageEnd()
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/twisted/websocket.py", line 318, in _onMessageEnd
    self.onMessageEnd()
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py", line 628, in onMessageEnd
    self._onMessage(payload, self.message_is_binary)
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/twisted/websocket.py", line 321, in _onMessage
    self.onMessage(payload, isBinary)
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/websocket/binance_client_protocol.py", line 30, in onMessage
    self.factory.callback(payload_obj)
  File "manage_local_order_book.py", line 113, in message_handler
    order_book = get_snapshot()
  File "manage_local_order_book.py", line 44, in get_snapshot
    return client.depth(symbol, limit=1000)
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/spot/market.py", line 62, in depth
    return self.query("/api/v3/depth", params)
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/api.py", line 67, in query
    return self.send_request("GET", url_path, payload=payload)
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/api.py", line 116, in send_request
    self._handle_exception(response)
  File "/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/api.py", line 169, in _handle_exception
    raise ClientError(status_code, err["code"], err["msg"], response.headers)
binance.error.ClientError: (400, -1100, "Illegal characters found in parameter 'symbol'; legal range is '^[A-Z0-9-_.]{1,20}$'.", {'Content-Type': 'application/json;charset=UTF-8', 'Content-Length': '108', 'Connection': 'keep-alive', 'Date': 'Sat, 17 Jul 2021 22:12:36 GMT', 'Server': 'nginx', 'x-mbx-uuid': 'a8859ae7-0935-4764-995e-ff8e2105217b', 'x-mbx-used-weight': '20', 'x-mbx-used-weight-1m': '20', 'Strict-Transport-Security': 'max-age=31536000; includeSubdomains', 'X-Frame-Options': 'SAMEORIGIN', 'X-Xss-Protection': '1; mode=block', 'X-Content-Type-Options': 'nosniff', 'Content-Security-Policy': "default-src 'self'", 'X-Content-Security-Policy': "default-src 'self'", 'X-WebKit-CSP': "default-src 'self'", 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'X-Cache': 'Error from cloudfront', 'Via': '1.1 76f9985b0c929a023355db8e462592f0.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'MIA3-C2', 'X-Amz-Cf-Id': 'h_yoGk29UvtjI_uFrubzpNRiHigG0_6cuZRPa79ikZ-6y_NbQLvH1g=='})

^CTraceback (most recent call last):
WARNING:root:WebSocket connection closed: connection was closed uncleanly (peer dropped the TCP connection without previous WebSocket closing handshake), code: 1006, clean: False, reason: connection was closed uncleanly (peer dropped the TCP connection without previous WebSocket closing handshake)
  File "manage_local_order_book.py", line 147, in <module>
ERROR:root:Lost connection to Server. Reason: [Failure instance: Traceback: <class 'binance.error.ClientError'>: (400, -1100, "Illegal characters found in parameter 
'symbol'; legal range is '^[A-Z0-9-_.]{1,20}$'.", {'Content-Type': 'application/json;charset=UTF-8', 'Content-Length': '108', 'Connection': 'keep-alive', 'Date': 'Sat, 17 Jul 2021 22:12:36 GMT', 'Server': 'nginx', 'x-mbx-uuid': 'a8859ae7-0935-4764-995e-ff8e2105217b', 'x-mbx-used-weight': '20', 'x-mbx-used-weight-1m': '20', 'Strict-Transport-Security': 'max-age=31536000; includeSubdomains', 'X-Frame-Options': 'SAMEORIGIN', 'X-Xss-Protection': '1; mode=block', 'X-Content-Type-Options': 'nosniff', 'Content-Security-Policy': "default-src 'self'", 'X-Content-Security-Policy': "default-src 'self'", 'X-WebKit-CSP': "default-src 'self'", 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'X-Cache': 'Error from cloudfront', 'Via': '1.1 76f9985b0c929a023355db8e462592f0.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'MIA3-C2', 'X-Amz-Cf-Id': 'h_yoGk29UvtjI_uFrubzpNRiHigG0_6cuZRPa79ikZ-6y_NbQLvH1g=='})
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/python/log.py:85:callWithContext
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/python/context.py:118:callWithContext
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/python/context.py:83:callWithContext
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/internet/posixbase.py:700:_doReadOrWrite
--- <exception caught here> ---
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/internet/posixbase.py:687:_doReadOrWrite
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/internet/tcp.py:246:doRead
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/internet/tcp.py:251:_dataReceived
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/protocols/tls.py:324:dataReceived
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/protocols/tls.py:290:_flushReceiveBIO
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/protocols/policies.py:107:dataReceived
/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/twisted/websocket.py:290:dataReceived
/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py:1207:_dataReceived
/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py:1219:consumeData
/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py:1579:processData
/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py:1704:onFrameEnd
/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/twisted/websocket.py:318:_onMessageEnd
/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py:628:onMessageEnd
/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/twisted/websocket.py:321:_onMessage
/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/websocket/binance_client_protocol.py:30:onMessage
manage_local_order_book.py:113:message_handler
manage_local_order_book.py:44:get_snapshot
/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/spot/market.py:62:depth
/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/api.py:67:query
/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/api.py:116:send_request
/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/api.py:169:_handle_exception
].

OK so I got it working, I’m not entirely sure what I managed to do but I have gotten it to finally work, however I do notice why you don’t want this to run on Windows, It has the a bug with Async, I’ve encountered this before, the sccript does not exit cleanly, or rather there is no way to exit the script cleanly because even if you throw a keyboard interrupt the websocket stays open and responds to server pings but doesnt close entirely. This is due to, from what I understand, the exception being thrown during a task but not making it to the scope of the top level handler.
If I may suggest adding the folloing to take car of this :

if __name__ == '__main__':
    try:
        main()
    except KeyboardInterrupt:
        os._exit(0)
1 Like

from the error log, the client already connected with websocket server successfully. I saw the server returned this:


binance.error.ClientError: (400, -1100, "Illegal characters found in parameter 'symbol'; legal range is '^[A-Z0-9-_.]{1,20}$'.", {'Content-Type': 'application/json;charset=UTF-8', 'Content-Length': '108', 'Connection': 'keep-alive', 'Date': 'Sat, 17 Jul 2021 22:12:34 GMT', 'Server': 'nginx', 'x-mbx-uuid': '3ef51bc8-1a87-4182-90ca-a0abd1c3fc46', 'x-mbx-used-weight': '10', 'x-mbx-used-weight-1m': '10', 'Strict-Transport-Security': 'max-age=31536000; includeSubdomains', 'X-Frame-Options': 'SAMEORIGIN', 'X-Xss-Protection': '1; mode=block', 'X-Content-Type-Options': 'nosniff', 'Content-Security-Policy': "default-src 'self'", 'X-Content-Security-Policy': "default-src 'self'", 'X-WebKit-CSP': "default-src 'self'", 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'X-Cache': 'Error from cloudfront', 'Via': '1.1 76f9985b0c929a023355db8e462592f0.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'MIA3-C2', 'X-Amz-Cf-Id': '6f5P9LxLM5k4loBTAbXeCa_9Ir7c-KunLm3ne63wzNyIf88dJ3uPVA=='})

it came from RESTful request that sent with wrong symbol, please share the raw request returned this error.