Python ThreadedWebsocketManager Error

I was trying to connect Binance Websocket, but Error happened. and I can’t find out what is the problem of it…

Can you help me please?

CODE

from binance import ThreadedWebsocketManager
import pandas as pd

def stream_data(msg):
‘’‘define how to process incoming WebSocket messages’‘’
print(msg)

twm = ThreadedWebsocketManager()
twm.start()


Exception in thread Thread-1:
Traceback (most recent call last):
File “C:\Users\akak1\AppData\Local\Programs\Python\Python39\lib\threading.py”, line 950, in _bootstrap_inner
self.run()
File “C:\Users\akak1\PycharmProjects\pythonProject9\venv\lib\site-packages\binance\threaded_stream.py”, line 56, in run
self._loop.run_until_complete(self.socket_listener())
File “C:\Users\akak1\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py”, line 642, in run_until_complete
return future.result()
File “C:\Users\akak1\PycharmProjects\pythonProject9\venv\lib\site-packages\binance\threaded_stream.py”, line 35, in socket_listener
self._client = await AsyncClient.create(loop=self._loop, **self._client_params)
File “C:\Users\akak1\PycharmProjects\pythonProject9\venv\lib\site-packages\binance\client.py”, line 7125, in create
await self.ping()
File “C:\Users\akak1\PycharmProjects\pythonProject9\venv\lib\site-packages\binance\client.py”, line 7246, in ping
return await self._get(‘ping’, version=self.PRIVATE_API_VERSION)
File “C:\Users\akak1\PycharmProjects\pythonProject9\venv\lib\site-packages\binance\client.py”, line 7211, in _get
return await self._request_api(‘get’, path, signed, version, **kwargs)
File “C:\Users\akak1\PycharmProjects\pythonProject9\venv\lib\site-packages\binance\client.py”, line 7174, in _request_api
return await self._request(method, uri, signed, **kwargs)
File “C:\Users\akak1\PycharmProjects\pythonProject9\venv\lib\site-packages\binance\client.py”, line 7155, in _request
async with getattr(self.session, method)(uri, **kwargs) as response:
File “C:\Users\akak1\PycharmProjects\pythonProject9\venv\lib\site-packages\aiohttp\client.py”, line 1187, in aenter
self._resp = await self._coro
File “C:\Users\akak1\PycharmProjects\pythonProject9\venv\lib\site-packages\aiohttp\client.py”, line 574, in _request
conn = await self._connector.connect(
File “C:\Users\akak1\PycharmProjects\pythonProject9\venv\lib\site-packages\aiohttp\connector.py”, line 544, in connect
proto = await self._create_connection(req, traces, timeout)
File “C:\Users\akak1\PycharmProjects\pythonProject9\venv\lib\site-packages\aiohttp\connector.py”, line 911, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
File “C:\Users\akak1\PycharmProjects\pythonProject9\venv\lib\site-packages\aiohttp\connector.py”, line 1173, in _create_direct_connection
hosts = await asyncio.shield(host_resolved)
File “C:\Users\akak1\PycharmProjects\pythonProject9\venv\lib\site-packages\aiohttp\connector.py”, line 884, in _resolve_host
addrs = await self._resolver.resolve(host, port, family=self._family)
File “C:\Users\akak1\PycharmProjects\pythonProject9\venv\lib\site-packages\aiohttp\resolver.py”, line 33, in resolve
infos = await self.loop.getaddrinfo(
File “C:\Users\akak1\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py”, line 856, in getaddrinfo
return await self.run_in_executor(
File “C:\Users\akak1\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py”, line 809, in run_in_executor
executor = concurrent.futures.ThreadPoolExecutor(
File "C:\Users\akak1\AppData\Local\Programs\Python\Python39\lib\concurrent\futures_init
.py", line 49, in getattr
from .thread import ThreadPoolExecutor as te
File “C:\Users\akak1\AppData\Local\Programs\Python\Python39\lib\concurrent\futures\thread.py”, line 37, in
threading._register_atexit(_python_exit)
File “C:\Users\akak1\AppData\Local\Programs\Python\Python39\lib\threading.py”, line 1370, in _register_atexit
raise RuntimeError(“can’t register atexit after shutdown”)
RuntimeError: can’t register atexit after shutdown

Process finished with exit code 0


Not enough info that can understand what cause this, however it seems you can’t connect to the server?

What is the websocket server address are you connecting?

Go to your python directory and click install_certificates.command and try again