Frequent Read Timeout = 7 Error.

rrjain
Hello,
I am frequently facing timeout error while reading orderbook. I am reading below code every 2 second to check the status of order i.e. whether it is changing status from "trigger pending" to "complete"

ordersdict = (pd.DataFrame(kite.orders())).set_index(['order_id'])

However many times I am getting below error...

HTTPSConnectionPool(host='api.kite.trade', port=443): Read timed out. (read timeout=7)

Can you please guide what needs to be done to resolve this..

Regards,
Ritesh Jain
  • sujith
    @rrjain,
    You need to use either order updates on websockets or postbacks to listen to event and then only fetch orderbook.
    Since you are polling the orderbook, CDN might be considering it as DDOS and limiting the requests.
  • rrjain
    @sujith

    Thanks for quick reply, do we have any reference code for fetching order updates on websocket..
  • sujith
    You need to set a listener for this.
  • rrjain
    @sujith I've updated my code as per below temporarily while i modify code as per above solution.. but this throwing error
    "name 'ReadTimeout' is not defined"

    am i missing something?


    from kiteconnect import exceptions

    try:
    Your Historical data fetching code logic
    except ReadTimeout:
    pass
    except exceptions.NetworkException:
    pass
  • rakeshr
    @rrjain
    "name 'ReadTimeout' is not defined"
    You need to import ReadTimeout for request.exception package.
    from requests.exceptions import ReadTimeout
Sign In or Register to comment.