Kite order POST returning 503 but order getting placed

Ajax
Hi @sujith @tonystark ,

Today I saw instances where POST /orders/bo was throwing 503 but the order was still getting placed.

[08/01/2018 09:21:01 AM] Starting new HTTPS connection (1): api.kite.trade
[08/01/2018 09:21:04 AM] https://api.kite.trade:443 "POST /orders/bo HTTP/1.1" 503 98
[08/01/2018 09:21:04 AM] [KiteClient] Network issue. Order place failed.. Retrying
[08/01/2018 09:21:04 AM] Starting new HTTPS connection (1): api.kite.trade
[08/01/2018 09:21:06 AM] https://api.kite.trade:443 "POST /orders/bo HTTP/1.1" 503 98
[08/01/2018 09:21:06 AM] [KiteClient] Network issue. Order place failed.. Retrying
[08/01/2018 09:21:06 AM] Starting new HTTPS connection (1): api.kite.trade
[08/01/2018 09:21:09 AM] https://api.kite.trade:443 "POST /orders/bo HTTP/1.1" 503 98
[08/01/2018 09:21:09 AM] [KiteClient] Network issue. Order place failed.. Retrying
[08/01/2018 09:21:09 AM] Starting new HTTPS connection (1): api.kite.trade
[08/01/2018 09:21:11 AM] https://api.kite.trade:443 "POST /orders/bo HTTP/1.1" 503 98
[08/01/2018 09:21:11 AM] [KiteClient] Network issue. Order place failed.. Retrying
[08/01/2018 09:21:11 AM] Starting new HTTPS connection (1): api.kite.trade
[08/01/2018 09:21:12 AM] https://api.kite.trade:443 "POST /orders/bo HTTP/1.1" 200 None




Please look into this and get this fixed ASAP. It is very hard to handle such cases from a client side and results into duplicate orders getting placed.

Tagged:
  • sujith
    Hi @Ajax,
    This can happen when Kite Trade doesn't receive order id while placing an order from the OMS. If you get a timeout while placing the order then your logic should be to fetch orderbook and check before repeating order.

    In this scenario, the order is placed but OMS didn't respond. So Kite trade will throw timeout. Make sure you add this check ASAP.
  • sujith
    We will ask the OMS team for an explanation for this but this can happen for many reasons at the OMS. It would be better if the client has this check to mitigate the risk.
  • Ajax
    Ajax edited August 2018
    @sujith: This is not a timeout. Instead this is a 503 which means that the server was unavailable to process request. According to HTTP conventions, this error code is something that is temporary and has to be re-tried.
    Adding hack in client to support server bugs should not be suggested professionally. Ideally all 503 status have to be re-tried. If it is timeout instead, please follow the HTTP convention and send proper error codes.

    Edit: I guess you got confused with the "Network issue" in the logs. Ignore that. That is a custom message that I am logging. From HTTP logs, you can see that it is a 503 instead.
Sign In or Register to comment.