Kotak-Neo / kotak-neo-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting error Connection is already closed while using feed API

rajendrasp opened this issue · comments

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?

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

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

it is their server issue.

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.