I ran examples in the official Binance API python package. But the websocket examples failed to connect to the server. The error is like
"2022-04-28 05:09:02.115 UTC INFO binance.websocket.binance_client_factory: Start to connect…
2022-04-28 05:09:02.775 UTC WARNING binance.websocket.binance_client_protocol: WebSocket connection closed: connection was closed uncleanly (SSL error: unregistered scheme (in )), code: 1006, clean: False, reason: connection was closed uncleanly (SSL error: unregistered scheme (in ))
2022-04-28 05:09:02.776 UTC ERROR binance.websocket.binance_client_factory: Lost connection to Server. Reason: [Failure instance: Traceback (failure with no frames): <class ‘twisted.internet.error.ConnectionDone’>: Connection was closed cleanly.
]. Retrying: 3 2022-04-28 05:09:03.723 UTC DEBUG root: closing ws connection"
I also could not link to the server by a simple url like wss://stream.binance.com:9443/ws/bnbbtc@depth
I added the winapi controlhandler because i have no Break key and this works with Ctrl-C.
You can use the Break/Pause key instead (Ctrl-Pause or Ctrl-ScrLk in the osk)
See this link for other solutions
(cmd, different IDEs, how to set environment variable permanently):
Are you by any chace on a windows machine?
I have the same error message, but when I run it through WSL,
i.e. via the Kali Linux distribution, it works.
You can install any distro like Ubuntu, Suse, Debian via the Microsoft store.
Run it like this without logging in in your current directory:
kali run 'python yourscript.py'
Both, my Windows 11 and WSL Kali Linux have Python 3.10.5, Twisted 22.4.0 and websockets 10.3.
I tried several online websocket test tool. I can reach other websocket servers but cannot connect to Binance’s. I use ExpressVPN for all networks. Does that matter?