'no close frame received or sent' issue

Hello @Dhan_Cares , @Hardik - Any update on this? Due to reconnection , the targeted price is missed resulting in losses.

Hello @Dhan_Cares , @Hardik - Any progress on the issue?..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

Hello @PravinJ ,

I am reaching out to express a significant concern I’ve been facing with the paid API services provided by Dhan. I have been experiencing frequent disconnection issues, which severely impact the performance and reliability of my trading activities. I am genuinely invested in using Dhan as my broker due to the robust features and services you offer, but this recurring issue is posing a challenge.

Despite reaching out to support, the issue remains unresolved. I would appreciate any additional support or escalation of this matter, as maintaining a stable connection is crucial to my operations.

Thank you for your attention to this matter, and I look forward to a resolution that helps me continue my journey with Dhan. Regards, Amit Kumar Aswani @Dhan_Cares , @Hardik

Hello @AmitKAswani

You must not be facing this issue any more, where random disconnection is happening. I understand the delay in response here, but it is possible to miss threads on community. Therefore, if it is a specific issue, will always recommend to raise a ticket on support channels.

Thanks @Hardik ! The issue is resolved now.

1 Like

@Hardik I sent email regarding this. Its happening again. @AmitKAswani is this happening again for you?

Hello @Santhosh_Murali

Have you updated your Websockets library? We are not seeing random disconnection on our server end.

Hello @AmitKAswani ,

Is this error resolved for you now?

“sent 1011 (internal error) keepalive ping timeout; no close frame received”

I am still getting this error sometimes. What version of dhanhq and websocket libraries you are using?

Hello @ajay_sanap - I’m using the latest version of dhanhq and version 13.0.1 of websockets. I too get the exception sometimes so reconnect it when the exception is thrown.

Hello @AmitKAswani,

Thanks for the reply.

Yes I have implemented reconnection logic. But today on reconnection as well as it was throwing this error again and again.

No , It’s working fine for me.

Ok. How many instruments you have subscribed to?

Atleast 9-10 instruments at a time

hey how your problem solved ??

I am getting same problem - sent 1011 (internal error) keepalive ping timeout; no close frame received

Hey @svadukia .

If you have subscribed to smaller number of instruments, then this problem may occur fewer times. Add reconnection logic. It may help.

If you have subscribed to larger number of instruments and doing lots of processing on them then depending on your CPU usage you will encounter this problem. Try to optimize your code and or reduce number of instruments and have a reconnection logic implemented.

1 Like

how did this issue is resolved? i am also getting same issue. what could be possible solution here. please suggest and share the solution

can you please share snippet of reconnection logic.

finally:
    # Close Connection if it was opened
    try:
        data.disconnect()
        print("Disconnected from WebSocket feed.")
    except:
        pass

is this above?

Hello @virender_singh - Don’t call the disconnect() function here. Infact, call the function which has this snippet in it …data.run_forever() when u receive the exception.

1 Like