Kite API Connectivity Issue :: requests.exceptions.ConnectionError: ('Connection aborted.'...)

vnshsingh
I faced ConnectionError issue with Kite API on 7-Aug-2025 and due to this order did not get placed. I run my script in a Windows Virtual Server. Ping tests always show as 2ms. Hence, no question or problem about connectivity from server side. Also, there is a sleep(1) in while loop in my python code, so script runs continuously till the end time.

Please note that I have already gone through a discussion that was similar to this error. The final response in that discussion was to use good internet connection. This suggestion is not applicable as I already have reliable and bullet proof internet connectivity.

Below is the error message that I received from Kite API along with python code that I use to place orders:

Error Message: requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))

Python Code to place Orders:
Nifty_Max_Qty_Per_Order = 1800
End_Time = datetime.now().replace(hour=15, minute=15, second=10)

def Condn_Check_Shift():
.....
.....
.....

def NS_PlaceSellOrder(symbolName, qty1):
loop = int(qty1 / Nifty_Max_Qty_Per_Order)
remainder = qty1 % Nifty_Max_Qty_Per_Order
run = 0
threads = []

def place_order(quantity):
kite.place_order(tradingsymbol=symbolName, exchange=kite.EXCHANGE_NFO, transaction_type=kite.TRANSACTION_TYPE_SELL, quantity=quantity, order_type=kite.ORDER_TYPE_MARKET, product=kite.PRODUCT_MIS, variety=kite.VARIETY_REGULAR)

if loop > 0:
while run < loop:
thread = threading.Thread(target=place_order, args=(Nifty_Max_Qty_Per_Order,))
threads.append(thread)
thread.start()
run += 1

if remainder != 0:
thread = threading.Thread(target=place_order, args=(remainder,))
threads.append(thread)
thread.start()
else:
thread = threading.Thread(target=place_order, args=(qty1,))
threads.append(thread)
thread.start()

# Wait for all threads to finish
for thread in threads:
thread.join()
print(f"Nifty sell {symbolName} {qty1} qty {datetime.now().isoformat(' ', 'seconds')}")


NS_PlaceSellOrder('NIFTY2580724500CE', 1500)
NS_PlaceSellOrder('NIFTY2580724500PE', 1500)
.....
.....
.....

while datetime.now() < End_Time:
Condn_Check_Shift()
sleep(1)
  • nagavenij
    You can refer to this discussion.
  • vnshsingh
    @nagavenij I have gone through the discussion that you have suggested. I am not calling get_position() function in my code.
  • nagavenij
    A connectivity error may occur across all endpoints. The error displays when you try to reuse a connection at the moment the server closes it due to inactivity or a local session timeout. You can retry the request after a brief delay of a few milliseconds.
  • SKUMAR
    API KEY - RECEIVED
    API secret - RECEIVED
    REQUEST TOKEN - RECEIVED
    Access Token - Not recived
  • nagavenij
    You can refer to this discussion
Sign In or Register to comment.