I am connecting to a websocket client and subscribing to some streams. But I keep on getting this error
"'WebSocket connection is closed: code = 1006 (connection closed abnormally [internal]), no reason'"
I don't know the reason. Googled the problem but no help. I am using websockets package. Below is my code.
async def streaming_data(url):
headers = await gives_auth(auth_url)
print(headers)
try:
async with websockets.client.connect(url,extra_headers=headers) as websocket:
response = await websocket.recv()
print(response)
except websockets.exceptions.InvalidHandshake:
print('Exception raised when a handshake request or response is invalid.')
except websockets.exceptions.InvalidURI:
print('Exception raised when an URI isn’t a valid websocket URI.')
except websockets.exceptions.InvalidStatusCode:
print('Handshake responce status code is invalid')
except Exception as e:
print('Error in making the Websocket Connection!!')
print(e.args)
loop = asyncio.new_event_loop()
stream_url=""
streams = [loop.create_task(streaming_data(stream_url))]
loop.run_until_complete(asyncio.wait(streams))
I am fairly new to this. Thanks for the help.