Kotak-Neo / kotak-neo-api

120 stars 112 forks source link

Getting error Connection is already closed while using feed API #209

Open rajendrasp opened 4 months ago

rajendrasp commented 4 months ago

I am using subscribe API from kotak neo for multiple stocks. I subscribe to each stock separately. Out of nowhere, I started getting following error on subscribing -

error from callback <bound method StartServer.on_open of <neo_api_client.HSWebSocketLib.StartServer object at 0x000001CAA3A462D0>>: Connection is already closed.

Following is the log of callbacks -

Kotak Neo 2FA session created successfully [on_open]: The Session has been Opened! [on_close]: The Session has been Closed! [on_open]: The Session has been Opened! [on_open]: The Session has been Opened! The Data has been Un-Subscribed [on_close]: [on_close]: The Session has been Closed!The Session has been Closed!

[OnError]: Connection to remote host was lost. [on_close]: The Session has been Closed! [OnError]: Connection is already closed.

Any idea what might be going wrong here?

crypt0inf0 commented 4 months ago

Its a common error, All the subscribed stocks will close after few minutes.

rajendrasp commented 4 months ago

Why are they closed without app closing the socket or app unsubscribing them? Can the timeout be changed for when they are automatically closed?

crypt0inf0 commented 4 months ago

it is their server issue.

Cloudman0011 commented 4 months ago

Subscribe all stock at once.. It is common error. You need to handle this when your connection is closed and call the subscribe method to reopen the connection.

rajendrasp commented 4 months ago

I cannot subscribe to all once since I need to subscribe to different stocks at different time of the day. And re-opening is not working. I am closing the app and starting agin with login and everything. But it still gives me same error for long time. After few mins, it starts working. They should fix this or suggest a valid workaround.