ConnectionResetError 104 connection reset by peer

code_for_trade
Inside infinite for loop, I am continuously checking for order completion, if an order is found completed I am stopping the loop. In the same loop when checking the order I received this exception.

requests.exceptions.ChunkedEncodingError: ("Connection broken: ConnectionResetError(104, 'Connection reset by peer')", ConnectionResetError(104, 'Connection reset by peer'))
  • May I know the cause of this exception?
  • Is there is any call back for an order update? (Like it's present in Java, GO SDK?)
  • API vs Web socket, what's recommended? Basically, I keep watch on orders whether they are triggered or not?
  • sujith
    Are you blocking the main thread that is receiving the ticks?
    You shouldn't block the main thread. You can use on_order_update callback and use that as an event to fetch orderbook. Again make sure you don't block thread while fetching orderbook

    It is up to you, you can use postbacks API or order update via websockets. Postback API only gets update for the orders that are placed via API but order updates via websockets are pushed for all orders.
  • code_for_trade
    I was not using WebSocket when I got this error, I was using plain API calls in a loop.

    on_order_update will receive all order update?
  • code_for_trade
    Today I get the below error

    'Connection aborted.', OSError(107, 'Transport endpoint is not connected'
  • sujith
    sujith edited September 7
    I was not using WebSocket when I got this error, I was using plain API calls in a loop.
    'Connection aborted.', OSError(107, 'Transport endpoint is not connected'
    The above error is because of the socket or thread connection dropdown. Are you sure about not having any blocked port in your system or by the service provider?
    Are you using pykiteconnect or you are writing your own wrapper? Can you paste the code that is throwing this error?
    And please paste the complete stack trace.
    on_order_update will receive all order update?
    Yes, it will be triggered when there is an order update. Go through this documentation to know more.
Sign In or Register to comment.