Read Timeout error when calling kite.orders()

AkashRam
Issue -
Code was working fine till last week and the present week I have been travelling. When computer sleeps after sometime, I get a read timeout error. Is this possibly due to internet issues as I didn't have any such issue before this week. I hadn't placed the code under the try except block till now which I am doing now, but would really appreciate the clarification on the issue. Thanks!
  • rakeshr
    When computer sleeps after sometime, I get a read timeout error
    Yes, mostly would be network disconnection. Can you paste here the complete error stack trace? That would give more clarity.
  • AkashRam
    Hi Rakesh, thanks for the response, had a similar issue after coming back home too, here is the error stack trace -
    Traceback (most recent call last):
    File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/urllib3/connectionpool.py", line 793, in urlopen
    response = self._make_request(
    ^^^^^^^^^^^^^^^^^^^
    File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/urllib3/connectionpool.py", line 537, in _make_request
    response = conn.getresponse()
    ^^^^^^^^^^^^^^^^^^
    File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/urllib3/connection.py", line 466, in getresponse
    httplib_response = super().getresponse()
    ^^^^^^^^^^^^^^^^^^^^^
    File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 1419, in getresponse
    response.begin()
    File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 331, in begin
    version, status, reason = self._read_status()
    ^^^^^^^^^^^^^^^^^^^
    File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 300, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
    http.client.RemoteDisconnected: Remote end closed connection without response

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
    ^^^^^^^^^^^^^
    File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/urllib3/connectionpool.py", line 847, in urlopen
    retries = retries.increment(
    ^^^^^^^^^^^^^^^^^^
    File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/urllib3/util/retry.py", line 470, in increment
    raise reraise(type(error), error, _stacktrace)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/urllib3/util/util.py", line 38, in reraise
    raise value.with_traceback(tb)
    File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/urllib3/connectionpool.py", line 793, in urlopen
    response = self._make_request(
    ^^^^^^^^^^^^^^^^^^^
    File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/urllib3/connectionpool.py", line 537, in _make_request
    response = conn.getresponse()
    ^^^^^^^^^^^^^^^^^^
    File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/urllib3/connection.py", line 466, in getresponse
    httplib_response = super().getresponse()
    ^^^^^^^^^^^^^^^^^^^^^
    File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 1419, in getresponse
    response.begin()
    File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 331, in begin
    version, status, reason = self._read_status()
    ^^^^^^^^^^^^^^^^^^^
    File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 300, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
    urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "/Users/akashram/PycharmProjects/Zerodha Algo/src/Test.py", line 874, in
    orders = kite.orders()
    ^^^^^^^^^^^^^
    File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/kiteconnect/connect.py", line 416, in orders
    return self._format_response(self._get("orders"))
    ^^^^^^^^^^^^^^^^^^^
    File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/kiteconnect/connect.py", line 861, in _get
    return self._request(route, "GET", url_args=url_args, params=params, is_json=is_json)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/kiteconnect/connect.py", line 916, in _request
    raise e
    File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/kiteconnect/connect.py", line 904, in _request
    r = self.reqsession.request(method,
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/requests/adapters.py", line 501, in send
    raise ConnectionError(err, request=request)
    requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
  • AkashRam
    Had the same issue now too, error stack trace is below, any help would be much appreciated @rakeshr Thanks!

    Traceback (most recent call last):
    File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/urllib3/connectionpool.py", line 793, in urlopen
    response = self._make_request(
    ^^^^^^^^^^^^^^^^^^^
    File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/urllib3/connectionpool.py", line 537, in _make_request
    response = conn.getresponse()
    ^^^^^^^^^^^^^^^^^^
    File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/urllib3/connection.py", line 466, in getresponse
    httplib_response = super().getresponse()
    ^^^^^^^^^^^^^^^^^^^^^
    File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 1419, in getresponse
    response.begin()
    File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 331, in begin
    version, status, reason = self._read_status()
    ^^^^^^^^^^^^^^^^^^^
    File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 300, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
    http.client.RemoteDisconnected: Remote end closed connection without response

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
    ^^^^^^^^^^^^^
    File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/urllib3/connectionpool.py", line 847, in urlopen
    retries = retries.increment(
    ^^^^^^^^^^^^^^^^^^
    File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/urllib3/util/retry.py", line 470, in increment
    raise reraise(type(error), error, _stacktrace)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/urllib3/util/util.py", line 38, in reraise
    raise value.with_traceback(tb)
    File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/urllib3/connectionpool.py", line 793, in urlopen
    response = self._make_request(
    ^^^^^^^^^^^^^^^^^^^
    File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/urllib3/connectionpool.py", line 537, in _make_request
    response = conn.getresponse()
    ^^^^^^^^^^^^^^^^^^
    File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/urllib3/connection.py", line 466, in getresponse
    httplib_response = super().getresponse()
    ^^^^^^^^^^^^^^^^^^^^^
    File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 1419, in getresponse
    response.begin()
    File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 331, in begin
    version, status, reason = self._read_status()
    ^^^^^^^^^^^^^^^^^^^
    File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 300, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
    urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "/Users/akashram/PycharmProjects/Zerodha Algo/src/Test.py", line 679, in
    orders = kite.orders()
    ^^^^^^^^^^^^^
    File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/kiteconnect/connect.py", line 416, in orders
    return self._format_response(self._get("orders"))
    ^^^^^^^^^^^^^^^^^^^
    File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/kiteconnect/connect.py", line 861, in _get
    return self._request(route, "GET", url_args=url_args, params=params, is_json=is_json)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/kiteconnect/connect.py", line 916, in _request
    raise e
    File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/kiteconnect/connect.py", line 904, in _request
    r = self.reqsession.request(method,
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Users/akashram/PycharmProjects/Zerodha Algo/.venv/lib/python3.12/site-packages/requests/adapters.py", line 501, in send
    raise ConnectionError(err, request=request)
    requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
  • MAG
    Code was working fine till last week and the present week I have been travelling. When computer sleeps after sometime, I get a read timeout error.
    You clearly were not on your original home network when you originally posted this. You said you are traveling.
    First of all if your computer/laptop is going to sleep, you will definitely have issues. Sleep means all processing is suspended and the computer enters power saving mode. So you need to ensure your computer/laptop does not go to sleep. If it's a laptop as I suspect, you need to connect it to power source continuously when the code is running (market hours).

    The second thing is the quality of your internet connection while you are travelling. If your connection is not stable, there is nothing anyone can do. The only option is to change locations to one where you get a stable internet connection.

    And if the problem continues after you got back home, it could be a problem with your internet connection, your computer/laptops power saving settings in bios or a network/network driver issue.
    Whatever it is, the issue is unique at your end. It is definitely not an issue at Zerodhas end or the forums would have been inundated with such messages. Thats pretty plain and simple logic.

    So you need to debug at your end.
    '/Users/akashram/' means you are using a Mac. What is the uptime? I would suggest you do a cold reboot once and try using wired network connection instead of wireless. Also keep an eye on resource usage in activity monitor. You may find some clues there. I have had Firefox go crazy hog all resources and then choke the system affecting other applications. Thats just one example.
  • AkashRam
    Thanks for the response @MAG, idea was only to confirm if it was an internet issue in the first place.
  • MAG
    Yes and which is why many of us here run our code on the cloud using AWS/GCP/Azure.
Sign In or Register to comment.