java.net.SocketTimeoutException: timeout

Kirubakaran
Hi Team,

I am getting socket time out exception,
below is the log details.

if i call the same method again i am getting the data.
Could you pls help me to fix this issue.

INFO: <-- HTTP FAILED: java.net.SocketTimeoutException: timeout
java.net.SocketTimeoutException: timeout
at okhttp3.internal.http2.Http2Stream$StreamTimeout.newTimeoutException(Http2Stream.kt:677)
at okhttp3.internal.http2.Http2Stream$StreamTimeout.exitAndThrowIfTimedOut(Http2Stream.kt:686)
at okhttp3.internal.http2.Http2Stream.takeHeaders(Http2Stream.kt:143)
at okhttp3.internal.http2.Http2ExchangeCodec.readResponseHeaders(Http2ExchangeCodec.kt:96)
at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.kt:106)
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:79)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:34)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:82)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:74)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.kt:219)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:197)
at okhttp3.internal.connection.RealCall.execute(RealCall.kt:148)
at com.zerodhatech.kiteconnect.kitehttp.KiteRequestHandler.getRequest(KiteRequestHandler.java:150)
at com.zerodhatech.kiteconnect.KiteConnect.getQuote(KiteConnect.java:692)

Thanks
  • sujith
    How often are you fetching the Quote?
  • Kirubakaran
    Evey 15 mins in Thread
  • sujith
    It is difficult to predict. It could be a network issue, you may try setting the read and write timeout in the Kite Request handler.
    You can know more here.
  • sujith
    Or try splitting into two requests if you are fetching data for too many instruments at once.
  • hedmondjohn
    Your Java socket shows SocketTimeoutException means that it takes too long to get respond from other device and your request expires before getting response. This exception is occurring on following condition.
    • Server is slow and default timeout is less, so just put timeout value according to you.
    • Server is working fine but timeout value is for less time. so change the timeout value.
    Solution: A developer can pre-set the timeout option for both client and server operations.

    From Client side:

    Socket socket = new Socket();
    SocketAddress socketAddress = new InetSocketAddress(host, port);
    socket.connect(socketAddress, 12000); //12000 are milli seconds

    From Server side:

    ServerSocket serverSocket = new new ServerSocket(port);
    serverSocket.setSoTimeout(12000);

Sign In or Register to comment.