Interuppted IO Exception on placing SL order

riteshgoel
Hi Team, i'm getting below exception while trying to place an SL order. Pasting the complete stack trace.

java.io.InterruptedIOException: interrupted
at okio.Timeout.throwIfReached(Timeout.kt:99) ~[okio-jvm-3.4.0.jar:na]
at okio.OutputStreamSink.write(JvmOkio.kt:53) ~[okio-jvm-3.4.0.jar:na]
at okio.AsyncTimeout$sink$1.write(AsyncTimeout.kt:102) ~[okio-jvm-3.4.0.jar:na]
at okio.RealBufferedSink.flush(RealBufferedSink.kt:268) ~[okio-jvm-3.4.0.jar:na]
at okhttp3.internal.http2.Http2Writer.flush(Http2Writer.kt:120) ~[okhttp-4.4.0.jar:na]
at okhttp3.internal.http2.Http2Connection.flush(Http2Connection.kt:408) ~[okhttp-4.4.0.jar:na]
at okhttp3.internal.http2.Http2Stream$FramingSink.close(Http2Stream.kt:626) ~[okhttp-4.4.0.jar:na]
at okio.ForwardingSink.close(ForwardingSink.kt:37) ~[okio-jvm-3.4.0.jar:na]
at okhttp3.internal.connection.Exchange$RequestBodySink.close(Exchange.kt:242) ~[okhttp-4.4.0.jar:na]
at okio.RealBufferedSink.close(RealBufferedSink.kt:287) ~[okio-jvm-3.4.0.jar:na]
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:60) ~[okhttp-4.4.0.jar:na]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100) ~[okhttp-4.4.0.jar:na]
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:34) ~[okhttp-4.4.0.jar:na]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100) ~[okhttp-4.4.0.jar:na]
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:82) ~[okhttp-4.4.0.jar:na]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100) ~[okhttp-4.4.0.jar:na]
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83) ~[okhttp-4.4.0.jar:na]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100) ~[okhttp-4.4.0.jar:na]
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:74) ~[okhttp-4.4.0.jar:na]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100) ~[okhttp-4.4.0.jar:na]
at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:197) ~[okhttp-4.4.0.jar:na]
at okhttp3.internal.connection.RealCall.execute(RealCall.kt:148) ~[okhttp-4.4.0.jar:na]
at com.zerodhatech.kiteconnect.kitehttp.KiteRequestHandler.postRequest(KiteRequestHandler.java:88) ~[kiteconnect-3.4.0.jar:na]
at com.zerodhatech.kiteconnect.KiteConnect.placeOrder(KiteConnect.java:389) ~[kiteconnect-3.4.0.jar:na]
at com.trade.autopilot.common.kite.service.OrderService.placeOrder(OrderService.java:112) ~[classes/:na]
at com.trade.autopilot.common.kite.service.OrderService.placeSLOrderOnSellOrderComplete(OrderService.java:192) ~[classes/:na]
at com.trade.autopilot.common.kite.service.PositionManagerService.onOptionSellHandler(PositionManagerService.java:88) ~[classes/:na]
at com.trade.autopilot.common.kite.service.PositionManagerService$1.onOrderUpdate(PositionManagerService.java:48) ~[classes/:na]
at com.zerodhatech.ticker.KiteTicker.parseTextMessage(KiteTicker.java:711) ~[kiteconnect-3.4.0.jar:na]
at com.zerodhatech.ticker.KiteTicker.access$800(KiteTicker.java:30) ~[kiteconnect-3.4.0.jar:na]
at com.zerodhatech.ticker.KiteTicker$3.onTextMessage(KiteTicker.java:258) ~[kiteconnect-3.4.0.jar:na]
at com.neovisionaries.ws.client.ListenerManager.callOnTextMessage(ListenerManager.java:352) ~[nv-websocket-client-2.3.jar:na]
at com.neovisionaries.ws.client.ReadingThread.callOnTextMessage(ReadingThread.java:260) ~[nv-websocket-client-2.3.jar:na]
at com.neovisionaries.ws.client.ReadingThread.callOnTextMessage(ReadingThread.java:238) ~[nv-websocket-client-2.3.jar:na]
at com.neovisionaries.ws.client.ReadingThread.handleTextFrame(ReadingThread.java:963) ~[nv-websocket-client-2.3.jar:na]
at com.neovisionaries.ws.client.ReadingThread.handleFrame(ReadingThread.java:746) ~[nv-websocket-client-2.3.jar:na]
at com.neovisionaries.ws.client.ReadingThread.main(ReadingThread.java:108) ~[nv-websocket-client-2.3.jar:na]
at com.neovisionaries.ws.client.ReadingThread.runMain(ReadingThread.java:64) ~[nv-websocket-client-2.3.jar:na]
at com.neovisionaries.ws.client.WebSocketThread.run(WebSocketThread.java:45) ~[nv-websocket-client-2.3.jar:na]
  • sujith
    Have you added callTimeout for the interceptor? This looks like some issue with Okhttp library. You can google it and figure out.
    It is not Kite Connect exception.
  • UDX753
    Hi Team,

    I'm getting the below exception while trying to place an SL order. It's a Kite exception in this case. (To give a background the Qty size=4500 in this failed case, however when I did the SL with Qty = 75(1 lot) an hour before it worked. Secondly the internet network is of high bandwidth and working fine both the times. All other tick data were flowing in well, at both times)..... Here's the console output message......

    ???? [11:14:21] Checking exit conditions: P&L=₹-225.00, SL=₹-350.00, Target=₹350.00, TSL=₹-100.00, TSLTarget=₹99999.00
    ???? [11:14:22] Checking exit conditions: P&L=₹-225.00, SL=₹-350.00, Target=₹350.00, TSL=₹-100.00, TSLTarget=₹99999.00
    ???? [11:14:22] Checking exit conditions: P&L=₹-450.00, SL=₹-350.00, Target=₹350.00, TSL=₹-100.00, TSLTarget=₹99999.00
    ???? STOP LOSS EXIT CONDITION MET!
    Current P&L: ₹-449.99999999999943 <= Stop Loss: ₹-350.0
    ???? EXIT TRIGGERED BY: Stop Loss
    ???? Final P&L Status:
    Current P&L: ₹-449.99999999999943
    Stop Loss: ₹-350.0
    Target Amount: ₹350.0
    TSL Activated: No
    ???? Position details at exit:
    NIFTY2590224450PE: Qty=4500, Avg=2.30, P&L=₹0.00
    NIFTY2590224400PE: Qty=-4500, Avg=1.95, P&L=₹0.00
    ???? Starting exit process...
    ???? Exiting 1 SELL positions...
    ???? Order params for NIFTY2590224400PE:
    Exchange: NFO
    Trading Symbol: NIFTY2590224400PE
    Quantity: 4500
    Product: NRML
    com.zerodhatech.kiteconnect.kitehttp.exceptions.InputException
    at com.zerodhatech.kiteconnect.kitehttp.KiteResponseHandler.dealWithException(KiteResponseHandler.java:55)
    at com.zerodhatech.kiteconnect.kitehttp.KiteResponseHandler.handle(KiteResponseHandler.java:21)
    at com.zerodhatech.kiteconnect.kitehttp.KiteRequestHandler.postRequest(KiteRequestHandler.java:90)
    at com.zerodhatech.kiteconnect.KiteConnect.placeOrder(KiteConnect.java:380)
    at zerodhaproject1.Z_TrackPnL_Exit.exitSellPositions(Z_TrackPnL_Exit.java:1640)
    at zerodhaproject1.Z_TrackPnL_Exit.lambda$startExitProcess$0(Z_TrackPnL_Exit.java:1595)
    ⚠️ 1 SELL positions still open!
    ???? Subscribed to 2 instruments for real-time P&L tracking
    ???? Refreshed positions data: 2 open positions, Stop Loss: ₹-350.00, Target: ₹350.00
    ⚠️ 1 SELL positions still open!
    at java.base/java.lang.Thread.run(Thread.java:1447)
    Sept 02, 2025 11:14:22 AM zerodhaproject1.Z_TrackPnL_Exit exitSellPositions
    SEVERE: Login or instrument cache error
    com.zerodhatech.kiteconnect.kitehttp.exceptions.InputException
    at com.zerodhatech.kiteconnect.kitehttp.KiteResponseHandler.dealWithException(KiteResponseHandler.java:55)
    at com.zerodhatech.kiteconnect.kitehttp.KiteResponseHandler.handle(KiteResponseHandler.java:21)
    at com.zerodhatech.kiteconnect.kitehttp.KiteRequestHandler.postRequest(KiteRequestHandler.java:90)
    at com.zerodhatech.kiteconnect.KiteConnect.placeOrder(KiteConnect.java:380)
    at zerodhaproject1.Z_TrackPnL_Exit.exitSellPositions(Z_TrackPnL_Exit.java:1640)
    at zerodhaproject1.Z_TrackPnL_Exit.lambda$startExitProcess$0(Z_TrackPnL_Exit.java:1595)
    at java.base/java.lang.Thread.run(Thread.java:1447)

  • UDX753
    Just so that, it's not incidental, I tried freshly for another set of orders to execute the SL(Qty size=4500 for this as well).. It failed too.... Here's the output....

    ✅ Ticker data resumed - monitoring normal
    ???? [12:19:22] Checking exit conditions: P&L=₹-225.00, SL=₹-200.00, Target=₹200.00, TSL=₹-100.00, TSLTarget=₹99999.00
    ???? STOP LOSS EXIT CONDITION MET!
    Current P&L: ₹-225.0000000000002 <= Stop Loss: ₹-200.0
    ???? EXIT TRIGGERED BY: Stop Loss
    ???? Final P&L Status:
    Current P&L: ₹-225.0000000000002
    Stop Loss: ₹-200.0
    Target Amount: ₹200.0
    TSL Activated: No
    ???? Position details at exit:
    NIFTY2590224300PE: Qty=-4500, Avg=1.20, P&L=₹-225.00
    NIFTY2590224350PE: Qty=4500, Avg=1.40, P&L=₹0.00
    ???? Starting exit process...
    ???? Exiting 1 SELL positions...
    ???? Order params for NIFTY2590224300PE:
    Exchange: NFO
    Trading Symbol: NIFTY2590224300PE
    Quantity: 4500
    Product: NRML
    com.zerodhatech.kiteconnect.kitehttp.exceptions.InputException
    at com.zerodhatech.kiteconnect.kitehttp.KiteResponseHandler.dealWithException(KiteResponseHandler.java:55)
    ⚠️ 1 SELL positions still open!
    at com.zerodhatech.kiteconnect.kitehttp.KiteResponseHandler.handle(KiteResponseHandler.java:21)
    at com.zerodhatech.kiteconnect.kitehttp.KiteRequestHandler.postRequest(KiteRequestHandler.java:90)
    at com.zerodhatech.kiteconnect.KiteConnect.placeOrder(KiteConnect.java:380)
    at zerodhaproject1.Z_TrackPnL_Exit.exitSellPositions(Z_TrackPnL_Exit.java:1640)
    at zerodhaproject1.Z_TrackPnL_Exit.lambda$startExitProcess$0(Z_TrackPnL_Exit.java:1595)
    at java.base/java.lang.Thread.run(Thread.java:1447)
    Sept 02, 2025 12:19:23 PM zerodhaproject1.Z_TrackPnL_Exit exitSellPositions
    SEVERE: Login or instrument cache error
    com.zerodhatech.kiteconnect.kitehttp.exceptions.InputException
    at com.zerodhatech.kiteconnect.kitehttp.KiteResponseHandler.dealWithException(KiteResponseHandler.java:55)
    at com.zerodhatech.kiteconnect.kitehttp.KiteResponseHandler.handle(KiteResponseHandler.java:21)
    at com.zerodhatech.kiteconnect.kitehttp.KiteRequestHandler.postRequest(KiteRequestHandler.java:90)
    at com.zerodhatech.kiteconnect.KiteConnect.placeOrder(KiteConnect.java:380)
    at zerodhaproject1.Z_TrackPnL_Exit.exitSellPositions(Z_TrackPnL_Exit.java:1640)
    at zerodhaproject1.Z_TrackPnL_Exit.lambda$startExitProcess$0(Z_TrackPnL_Exit.java:1595)
    at java.base/java.lang.Thread.run(Thread.java:1447)

    ???? Subscribed to 2 instruments for real-time P&L tracking
    ???? Refreshed positions data: 2 open positions, Stop Loss: ₹-200.00, Target: ₹200.00
    ⚠️ 1 SELL positions still open!
    ???? Subscribed to 2 instruments for real-time P&L tracking
    ???? Refreshed positions data: 2 open positions, Stop Loss: ₹-200.00, Target: ₹200.00
    ⚠️ 1 SELL positions still open!
  • sujith
    You need to either enable debug logs for javakiteconnect or print the KiteException message and check the reason.
  • sujith
    You may refer to the sample here.
  • UDX753
    Sujith, thanks for the input. It worked fine, after breaking the orders. Is Iceberg provision not available in API? Secondly, I have a concern, if due to a network or some reason the exit API fails, it shall lead to a big loss since I'm planning large quantities. Can you advise what fool proof or backup mechanism are followed by season algo traders to ensure, exits are FAIL PROOF. Even if you share some article (or) refer some one where I could lbe guided on this it shall be very helpful.
  • Nivas
    Is Iceberg provision not available in API?
    You can place iceberg orders via API. You may refer to the sample here.
    Can you advise what fool proof or backup mechanism are followed by season algo traders to ensure, exits are FAIL PROOF
    Kite Connect is an execution platform. I am afraid we can't provide support/advice for writing code.
Sign In or Register to comment.