Not able to fetch the data

Hi Team,

I am facing issue while fetching data, everything was wroking fine till yesterday, no change from my side but suddenly from today morning my code is stuck, throwing following exception
Error in fetching intra daya data NSE_INDEX|Nifty 50 1minute
Traceback (most recent call last):
File “c:\Python312\Lib\site-packages\websockets\legacy\client.py”, line 647, in await_impl_timeout
return await self.await_impl()
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “c:\Python312\Lib\site-packages\websockets\legacy\client.py”, line 651, in await_impl
_transport, _protocol = await self._create_connection()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “c:\Python312\Lib\asyncio\base_events.py”, line 1101, in create_connection
sock = await self._connect_sock(
^^^^^^^^^^^^^^^^^^^^^^^^^
File “c:\Python312\Lib\asyncio\base_events.py”, line 1004, in _connect_sock
await self.sock_connect(sock, address)
File “c:\Python312\Lib\asyncio\proactor_events.py”, line 727, in sock_connect
return await self._proactor.connect(sock, address)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “E:\stk\PyProject\UpstoxAutomation\upstoxapi.py”, line 141, in getWebSocketRecentData
asyncio.run(WebSocketClient.fetch_market_data(instrument_key))
File “c:\Python312\Lib\asyncio\runners.py”, line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File “c:\Python312\Lib\asyncio\runners.py”, line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “c:\Python312\Lib\asyncio\base_events.py”, line 684, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File “E:\stk\PyProject\UpstoxAutomation\WebSocketClient.py”, line 54, in fetch_market_data
async with websockets.connect(response.data.authorized_redirect_uri, ssl=ssl_context) as websocket:
File “c:\Python312\Lib\site-packages\websockets\legacy\client.py”, line 629, in aenter
return await self
^^^^^^^^^^
File “c:\Python312\Lib\site-packages\websockets\legacy\client.py”, line 646, in await_impl_timeout
async with asyncio_timeout(self.open_timeout):
File “c:\Python312\Lib\asyncio\timeouts.py”, line 115, in aexit
raise TimeoutError from exc_val
TimeoutError
Error in Signal Check
Traceback (most recent call last):
File “E:\stk\PyProject\UpstoxAutomation\main.py”, line 92, in checkEntrySignal1
candleData = uplinkObj.customCandleData(symConfig[‘instrument’],Config.TRADE_TIMEFRAME)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “E:\stk\PyProject\UpstoxAutomation\upstoxapi.py”, line 258, in customCandleData
recentData_High = recentData[‘high’]
~~~~~~~~~~^^^^^^^^
TypeError: ‘NoneType’ object is not subscriptable

Please give some solution why is it comming today ?

Hi Team,

Can you please provide any update on this ?

Thanks

Hi @ShalabhSaurabh,

The error message suggests that there was a timeout in the WebSocket connection, indicating that the WebSocket client could not establish a connection within the specified timeout period.

To address this issue, we recommend increasing the timeout by setting the timeout parameter when calling websockets.connect.

For a simpler implementation of WebSocket functionality, you can explore the streamer features available in various SDKs:

Thank you!

but what will be the result by increasing timeout ? question is, why is it taking so much time, how will we place order in seconds if it takes lot of time?