ReadTimeoutError just after the market start!

mdalvi
2019-02-04 09:15:12,280 __main__ CRITICAL ReadTimeout(ReadTimeoutError("HTTPSConnectionPool(host='api.kite.trade', port=443): Read timed out. (read timeout=7)"))
Let me know what is supposed to be done so I could continue in 'exception' block!
except ReadTimeout:
?
Is re-instantiation of kite object a way to go? Also, what'sup with the error?
  • rakeshr
    @mdalvi
    We are already looking to timeout error.For time being you can handle timeout exception in your code.
    from requests.exceptions import ReadTimeout
    except ReadTimeout:
    pass
  • mdalvi
    mdalvi edited February 4
    from kiteconnect import KiteConnect
    from requests.exceptions import ReadTimeout


    class Kite(object):
    def __init__(self, **kite_credentials):
    self.kite = KiteConnect(**kite_credentials, debug=True)

    def exec(self, func_name, **kwargs):

    while True:
    try:
    return getattr(self.kite, func_name)(**kwargs)
    except ReadTimeout:
    pass
    is this an acceptable approach?
  • rakeshr
    @mdalvi
    Yeah, this is correct.
  • Srik
    I got the same issue on June 14th. Is this issue fixed or we still need to go with the same workaround?
  • rakeshr
    @Srik
    I got the same issue on June 14th. Is this issue fixed or we still need to go with the same workaround?
    In which of the APIs request, did you got TimeoutError?
  • Srik
    I’m getting this on order_history. I got it even today. Connection is getting disconnected often because of this.
  • Srik
    Traceback (most recent call
    order = pyTrade.order_history(order_id=stockCtx['orderId'])
    File "build\bdist.win-amd64\egg\kiteconnect\connect.py", line 387, in order_history

    File "build\bdist.win-amd64\egg\kiteconnect\connect.py", line 697, in _get

    File "build\bdist.win-amd64\egg\kiteconnect\connect.py", line 745, in _request

    requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.kite.trade', port=443): Read timed out.
  • rakeshr
    @Srik
    We checked for multiple order_history API response at our end, not able to reproduce Timeout exception at any instance. Make sure that you have added proper delay between multiple API calls.
  • Srik
    I’m calling this API once in a tick. Is it ok?
  • sujith
    We don't recommend polling API for listening to the status of an order. You can use postbacks API or order updates on the websockets.
  • Srik
    Can you please point to an example for post back and web socket methods for getting the order status?
  • Srik
    Srik edited June 19
    In the websocket call back on_order_update(ws,data), argument data is same as that of order_history return value? I mean the structure.
  • sujith
    You will receive a payload same as the postback response. You can check out the documentation here.
  • Srik
    Whether the data will be of the order whose status is changed or entire day’s orders.
  • Srik
    Also I see that I don’t get the call back posted after reconnection if the state changed during disconnection time. How to handle this.
  • rakeshr
    rakeshr edited June 20
    @Srik
    Whether the data will be of the order whose status is changed or entire day’s orders
    .
    It's only for the order whose order_status is changed, while WebSocket code is running.
    Also I see that I don’t get the call back posted after reconnection if the state changed during disconnection time. How to handle this.
    Post back status is received only for orders whose status is changed during your WebSocket code running.
    In case of disconnection, once you reconnect, you can fetch complete orderbook once and check change status for required order, check the documentation here.
Sign In or Register to comment.