Cant have a stable connection to fyers API

@HvxNu5uhfN @tejas_khoday

I am unable to have a stable websocket connection for the past 2 days, which gets disconnected between 10:50 - 11:20 AM or roughly after an hour I start my socket connection. Below I have attached the Error log.

Appreciate an immediate resolution.

Task exception was never retrieved
future:  exception=ConnectionClosedError('code = 1006 (connection closed abnormally [internal]), no reason')>
Traceback (most recent call last):
  File "/home/red/.local/lib/python3.9/site-packages/websockets/[protocol.py](http://protocol.py)", line 827, in transfer_data
    message = await [self.read](http://self.read)_message()
  File "/home/red/.local/lib/python3.9/site-packages/websockets/[protocol.py](http://protocol.py)", line 895, in read_message
    frame = await [self.read](http://self.read)_data_frame(max_size=self.max_size)
  File "/home/red/.local/lib/python3.9/site-packages/websockets/[protocol.py](http://protocol.py)", line 971, in read_data_frame
    frame = await [self.read](http://self.read)_frame(max_size)
  File "/home/red/.local/lib/python3.9/site-packages/websockets/[protocol.py](http://protocol.py)", line 1047, in read_frame
    frame = await [Frame.read](http://Frame.read)(
  File "/home/red/.local/lib/python3.9/site-packages/websockets/[framing.py](http://framing.py)", line 105, in read
    data = await reader(2)
  File "/usr/lib/python3.9/asyncio/[streams.py](http://streams.py)", line 723, in readexactly
    await self._wait_for_data('readexactly')
  File "/usr/lib/python3.9/asyncio/[streams.py](http://streams.py)", line 517, in _wait_for_data
    await self._waiter
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/red/.local/lib/python3.9/site-packages/fyers_api/websocket/[ws.py](http://ws.py)", line 239, in ping1
    await websocket.send(json.dumps("ping"))
  File "/home/red/.local/lib/python3.9/site-packages/websockets/[protocol.py](http://protocol.py)", line 555, in send
    await self.ensure_open()
  File "/home/red/.local/lib/python3.9/site-packages/websockets/[protocol.py](http://protocol.py)", line 812, in ensure_open
    raise self.connection_closed_exc()
websockets.exceptions.ConnectionClosedError: code = 1006 (connection closed abnormally [internal]), no reason

Hi @immaturetrader ,

We will get this checked and will reply back to you tomorrow at the earliest.

We just need one clarification from your end are you getting this while using jupyter notebook or an IDE.

This will help me to replicate the issue on a quicker basis and accordingly will update you on this too.

Thanks for bringing this to our notice.

Thanks and Regards

Piyush Kapse

I use Pycharm IDE.

Hi @immaturetrader ,

We will be rolling out a new websocket release here is a glimpse of how the new websocket would be working.

i would like to share a wheel file over here as currently it is in beta phase and also some sample scripts to get started with.
Your review and also your feedback would be much appreciated so we can add make changes based on your pointers.

if possible if you can share your mail_id will share the whole Zip bundle with you and also will be giving you an update with respect to the issue you mentioned in some time.

Changelog :

  1. Added Background/foreground process
  2. Handling of log files from user end
  3. Usage of threading instead of async calls

Thanks and Regards,
Piyush Kapse

Is the version Rolled out? If not can you please mail me the zip file?