The server didn't respond in time.

nkodela
I am running a python script on amazon web services in the background using the "screen" GUI option.
But when I check the code always stops executing after every few minutes with the following error.
Please let me know what is the issue because I want the code to run automatically without me checking every few minutes.


Traceback (most recent call last): File "SMA_Live.py", line 25, in records = kite.historical_data(token, from_date=fromdate, to_date=todate, interval=interval) File "/home/ubuntu/.local/lib/python3.8/site-packages/kiteconnect/connect.py", line 624, in historical_data data = self._get("market.historical", File "/home/ubuntu/.local/lib/python3.8/site-packages/kiteconnect/connect.py", line 826, in _get return self._request(route, "GET", url_args=url_args, params=params, is_json=is_json) File "/home/ubuntu/.local/lib/python3.8/site-packages/kiteconnect/connect.py", line 904, in _request raise ex.DataException("Unknown Content-Type ({content_type}) with response: ({content})".format( kiteconnect.exceptions.DataException: Unknown Content-Type (text/html) with response: (b"

504 Gateway Time-out

\nThe server didn't respond in time.\n\n")
  • sujith
    It seems like your requests are getting timed out. You should catch the exception and retry after some time.
  • nkodela
    I am new to python. I am just learning.
    Can you please share a code or some resources on how to reconnect without getting the script stop running?
  • nkodela
    @sujith
    thanks for the help.
    I have found the code for using try and except by searching online.
    I have implemented the same and its working fine.


    This thread can be closed now.
This discussion has been closed.