Websockets keep getting closed

Hi there,

When establishing a live market feed connection through DhanFeed, it keeps getting closed.
The websockets are failing with this Error: 1006.

I tried establishing multiple DhanFeed connections at once and only listening to one at a time, but all of my concurrent connections are dropping simultaneously.

Is there something which I am missing or need to do to keep the connection alive.
Would love any help, thanks !

Note that the time after which the websocket connection closes is generally between 10-20 minutes.

I am using dhanhq’s Node Library (API v1 implementation) - (Can shifting to v2 solve this issue?)

Maybe. I already asked to implement it in V2 by Dhan Team, but due to work I traveled out of country, so I could not complete it. Will update shortly once published. Meantime would you like to contribute, please create PR :slight_smile:

1 Like

Thanks @vinay_sd17 for the prompt reply, pls check: Need repo push rights for pull request [API v2] · Issue #18 · dhan-oss/DhanHQ-js · GitHub

Hello @arshpanghal - Were you able to trouble shoot the issue and does the pull request contains the fix? Appreciate your response.

The PR just aims to move to API V2,

Though while troubleshooting I suspect that this might possibly be due to packet loss on my network. Will try on better network conditions if this is still reproducible.

Are you facing the same issue and if yes, what is the generic time period after this is happening with you?

Hello @arshpanghal - I don’t think this is a packet loss issue. I suspected the same and moved to AWS but it’s the same problem. I’m facing this issue since I started using the live feed and it has not worked for me at all. It keeps disconnecting randomly…Traceback (most recent call last):
File “/home/ec2-user/.local/lib/python3.9/site-packages/websockets/legacy/protocol.py”, line 628, in send
await self.ensure_open()
File “/home/ec2-user/.local/lib/python3.9/site-packages/websockets/legacy/protocol.py”, line 938, in ensure_open
raise self.connection_closed_exc()
websockets.exceptions.ConnectionClosedError: sent 1011 (internal error) keepalive ping timeout; no close frame received
2024-10-29 09:52:26,012 - ERROR - Unexpected WebSocket closure: sent 1011 (internal error) keepalive ping timeout; no close frame received…Also tagging @Tradehull_Imran to suggest a resolution if possible.

Facing the same problem upon using the node library V2, even I am using the strong internet connection, but still facing the same problem.

@Dhan @Dhan_Cares @RahulDeshpande @Hardik
Guys, would love to hear your comments here, I am able to see a lot of similar threads on the community page.

Is this issue being checked ? could not be solved ? fix is ready ? being planned ?
Any update would help here.

Thanks

Hello @arshpanghal

Yes, we have already moved the library to V2 and minimise the issue of random websocket closure for maximum users. We are looking into further optimising this so as to ensure a more stable and reliable connection.

it is happening with me again and again.

do you have solution for it?

Hi @virender_singh
I think the dhan team is really not looking into the issue for some reason.
Even though they say that they’ve migrated to v2, the node lib is still under v1.0.6
and even though I volunteered for upgrading it to v2, no one actually catered it.

With deep agony, I think its best for all us to migrate to zerodha APIs at best. :pensive:

With so much vision in the company’s foundations, really didn’t expect so cheap implementations, and I hope somehow someday, they will be able to overcome these challenges.

Hello @virender_singh @arshpanghal

If this is on Node JS, will come up with the library upgrade soon, and take all the PRs that have been created on GitHub.

Also, @arshpanghal if you volunteer, would love to make you contributor on the library directly.

1 Like