Yes, our Upstox WebSocket connections utilize heartbeat messages to maintain the connection’s aliveness. Most well-known WebSocket client libraries across various programming languages handle heartbeat messages automatically. These libraries manage the sending and receiving of heartbeat messages behind the scenes, ensuring your connection remains active without any additional code for heartbeats on your part.
We recommend selecting a reputable WebSocket client library that suits your development environment and language preferences to seamlessly handle these heartbeats. By doing so, you can focus on consuming the updates from our feed without worrying about the underlying connection maintenance.
For examples and guidance on WebSocket implementation, please refer to our sample implementation at: Sample Implementation | Upstox Developer API. This resource should provide you with the necessary information to get started and make the most of our WebSocket services.
If you have any further questions or require additional assistance, please don’t hesitate to reach out.
The ping-pong mechanism for heartbeat is already part of our implementation but wasn’t documented. We’ll make sure to update the documentation to brief the same.
My connection is established & later disconnected with following error message. This message comes when I send a ping. My pings are a simple text message with word ping.
WS connection closed. Status [CloseStatus[code=1003, reason=Client messages not supported]]
So, it seems this is the cause. Please give me the exact format of the heartbeat message.
Our WebSocket server sends out ping events, expecting a corresponding pong response. Most WebSocket clients across various programming languages handle this automatically. If you choose to customize the default behavior, you should ensure your client listens for pings and sends back pongs accordingly.
We accept any general payload with the pong response and do not require a specific format.
Mention the format in docs that you use standard ping frame. If you go through the docs of other brokers, many are using different formats for hearbeat ping/pong. So, users of the api who have worked across different brokers would be looking for this information.