I have been using Upstox WebsocketV3 for some time for running a strategy and only in a past few days i have been facing more errors with stream disconnection which causes the bot to completely stop… Is this an issue from my side and if any comments on how i can improve it so that i face less disconnection…
I subscribe to one instrument at the beginning but can subscribe using the subscribe function to few more instruments during execution, the subscription goes fine but I have seen the no of disconnects rising in the last few days.
Also got this error when trying to get the option chain for a certain instrument:
2025-06-20 10:04:53,891 WARNING Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='api.upstox.com', port=443): Read timed out. (read timeout=None)")': /v2/option/contract?instrument_key=BSE_INDEX%7CSENSEX
Error in Websocket:
2025-06-20 09:55:57 ERROR [swing_bot.py | on_error]: Stream error received: Connection timed out
2025-06-20 09:55:57 INFO [swing_bot.py | on_close]: Connection closed. Code: None, Reason: None
2025-06-20 09:55:57 INFO [swing_bot.py | on_reconnecting]: Reconnecting... Auto reconnect attempt 1/10
2025-06-20 09:56:00 ERROR [swing_bot.py | on_error]: Stream error received: Handshake status 403 Forbidden -+-+- {'date': 'Fri, 20 Jun 2025 04:25:59 GMT', 'transfer-encoding': 'chunked', 'connection': 'keep-alive'} -+-+- None
2025-06-20 09:56:02 INFO [swing_bot.py | on_reconnecting]: Reconnecting... Auto reconnect attempt 2/10
2025-06-20 09:56:06 ERROR [swing_bot.py | on_error]: Stream error received: Handshake status 403 Forbidden -+-+- {'date': 'Fri, 20 Jun 2025 04:26:05 GMT', 'transfer-encoding': 'chunked', 'connection': 'keep-alive'} -+-+- None
2025-06-20 09:56:08 INFO [swing_bot.py | on_reconnecting]: Reconnecting... Auto reconnect attempt 3/10
2025-06-20 09:56:11 ERROR [swing_bot.py | on_error]: Stream error received: Handshake status 403 Forbidden -+-+- {'date': 'Fri, 20 Jun 2025 04:26:10 GMT', 'transfer-encoding': 'chunked', 'connection': 'keep-alive'} -+-+- None
2025-06-20 09:56:13 INFO [swing_bot.py | on_reconnecting]: Reconnecting... Auto reconnect attempt 4/10
2025-06-20 09:56:19 ERROR [swing_bot.py | on_error]: Stream error received: Handshake status 403 Forbidden -+-+- {'date': 'Fri, 20 Jun 2025 04:26:16 GMT', 'transfer-encoding': 'chunked', 'connection': 'keep-alive'} -+-+- None
2025-06-20 09:56:21 INFO [swing_bot.py | on_reconnecting]: Reconnecting... Auto reconnect attempt 5/10
2025-06-20 09:56:32 ERROR [swing_bot.py | on_error]: Stream error received: Handshake status 403 Forbidden -+-+- {'date': 'Fri, 20 Jun 2025 04:26:31 GMT', 'transfer-encoding': 'chunked', 'connection': 'keep-alive'} -+-+- None
2025-06-20 09:56:34 INFO [swing_bot.py | on_reconnecting]: Reconnecting... Auto reconnect attempt 6/10
2025-06-20 09:56:36 ERROR [swing_bot.py | on_error]: Stream error received: Handshake status 403 Forbidden -+-+- {'date': 'Fri, 20 Jun 2025 04:26:35 GMT', 'transfer-encoding': 'chunked', 'connection': 'keep-alive'} -+-+- None
2025-06-20 09:56:38 INFO [swing_bot.py | on_reconnecting]: Reconnecting... Auto reconnect attempt 7/10
2025-06-20 09:56:43 ERROR [swing_bot.py | on_error]: Stream error received: Handshake status 403 Forbidden -+-+- {'date': 'Fri, 20 Jun 2025 04:26:41 GMT', 'transfer-encoding': 'chunked', 'connection': 'keep-alive'} -+-+- None
2025-06-20 09:56:45 INFO [swing_bot.py | on_reconnecting]: Reconnecting... Auto reconnect attempt 8/10
2025-06-20 09:56:49 ERROR [swing_bot.py | on_error]: Stream error received: Handshake status 403 Forbidden -+-+- {'date': 'Fri, 20 Jun 2025 04:26:47 GMT', 'transfer-encoding': 'chunked', 'connection': 'keep-alive'} -+-+- None
2025-06-20 09:56:51 INFO [swing_bot.py | on_reconnecting]: Reconnecting... Auto reconnect attempt 9/10
2025-06-20 09:56:53 ERROR [swing_bot.py | on_error]: Stream error received: Handshake status 403 Forbidden -+-+- {'date': 'Fri, 20 Jun 2025 04:26:51 GMT', 'transfer-encoding': 'chunked', 'connection': 'keep-alive'} -+-+- None
2025-06-20 09:56:55 INFO [swing_bot.py | on_reconnecting]: Reconnecting... Auto reconnect attempt 10/10
2025-06-20 09:56:58 ERROR [swing_bot.py | on_error]: Stream error received: Handshake status 403 Forbidden -+-+- {'date': 'Fri, 20 Jun 2025 04:26:56 GMT', 'transfer-encoding': 'chunked', 'connection': 'keep-alive'} -+-+- None
2025-06-20 09:56:58 CRITICAL [swing_bot.py | on_auto_reconnect_stopped]: Auto-reconnect stopped after retry limit reached with retryCount of 10 exhausted.