urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='api.kite.trade', port=443): Read time

I am placing an order using API. The order is getting placed on console but the function call is not returning the order_ID which is leading to multiple order placement.
Why is it happening? Can anyone guide?
  • rakeshr
    Are you using place_order method to place order above?
    Are you getting ReadTimeoutError urllib3.exceptions.ReadTimeoutError:, while placing the above order?
    Can you paste the complete debug log for the above request as well?
  • sujith
    It is not a good practice to retry without checking in case of write requests. You can read more about it here.
  • maheshsolanke
    Thanks, @Leena for raising the issue.
    I also observed the same issue after the order is getting placed with the place_order() function but didn't return the order id.

    yup @sujith that's correct but how can we check if the order gets placed or not if we didn't have any order id in our hand.

  • maheshsolanke
    @sujith in this thread you have suggested at the last to check orderbook and retry for all non-400 write API responses how to check all non-400 write api response
  • rakeshr
    how can we check if the order gets placed or not if we didn't have any order id in our hand
    You can look for order_timestamp field in orderbook for each placed order.
  • Leena
    Thanks for replying @sujith @rakeshr @maheshsolanke

    yes I have pasted the complete log below @rakeshr

    I didn't got orderid for the order I placed using place_order()

    Traceback (most recent call last):
    kite.modify_order(variety= allorder_details_dict[stock][stoploss_order_id]['variety'], order_id= stoploss_order_id, parent_order_id= None, quantity= None, price= None, trigger_price = swing_low, validity = None , disclosed_quantity = None)
    File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\kiteconnect\connect.py", line 377, in modify_order
    File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\kiteconnect\connect.py", line 834, in _put
    return self._request(route, "PUT", url_args=url_args, params=params, is_json=is_json)
    File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\kiteconnect\connect.py", line 898, in _request
    raise exp(data["message"], code=r.status_code)
    kiteconnect.exceptions.GeneralException: Couldn't find that `order_id`.
  • rakeshr
    urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='api.kite.trade', port=443): Read timed out. (read timeout=7)
    Saw your error log above. An instance of time-out has happened, which can happen because of multiple reasons including local network connection, etc. What you need to do in such cases is handle read-timeout instances at your end and place an order again after checking the order book(check if order is already placed before raising time-out). Something like:
    from requests.exceptions import ReadTimeout
    # Place order
    except ReadTimeout:
    # fetch complete orderbook and check if order is already place
    # if place skip or else place same order again
  • Leena
    okay @rakeshr @sujith
    Thanks for support.
Sign In or Register to comment.