B4J Question How to fix or remove from log this error? java.net.SocketTimeoutException: timeout

jtare

Active Member
Licensed User
Longtime User
The b4j code is running with no ui on the server background, I use the log to read what is going on but this error keeps showing up, making very annoying the process of reading the log, it doesn't stop the program, only shows the error in the log.
I couldn't identify the change I did that causes this error. Each request is released at the end. I make one request at the time.

Any idea what could be causing this?

B4X:
Sub main
Wait For(api.requestsomething(link,token)) Complete (resp As Map)
End sub

Public Sub requestsomething(link As String, token As String) As ResumableSub
    Dim resp As Map
    resp.Initialize
    resp.Put("success",False)
        Dim j As HttpJob
        j.Initialize("", Me)
        j.Download2(link,Array As String("param","1"))
        j.GetRequest.SetHeader("Authorization", token)
        j.GetRequest.Timeout = 10000
        Wait For (j) JobDone(j As HttpJob)
        resp.Put("success",j.Success)
        If j.Success Then
                resp.Put("data",j.GetString)
        End If
        j.Release
    Return resp
End Sub

B4X:
java.net.SocketTimeoutException: timeout
    at okio.Okio$4.newTimeoutException(Okio.java:227)
    at okio.AsyncTimeout.exit(AsyncTimeout.java:284)
    at okio.AsyncTimeout$2.read(AsyncTimeout.java:240)
    at okio.RealBufferedSource.indexOf(RealBufferedSource.java:325)
    at okio.RealBufferedSource.indexOf(RealBufferedSource.java:314)
    at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:210)
    at okhttp3.internal.http1.Http1Codec.readResponse(Http1Codec.java:191)
    at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:132)
    at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:54)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
    at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
    at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
    at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
    at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
    at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:179)
    at okhttp3.RealCall.execute(RealCall.java:63)
    at anywheresoftware.b4h.okhttp.OkHttpClientWrapper.executeWithTimeout(OkHttpClientWrapper.java:156)
    at anywheresoftware.b4h.okhttp.OkHttpClientWrapper.access$0(OkHttpClientWrapper.java:153)
    at anywheresoftware.b4h.okhttp.OkHttpClientWrapper$ExecuteHelper.run(OkHttpClientWrapper.java:201)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: javax.net.ssl.SSLException: Socket closed
    at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:127)
    at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:326)
    at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:269)
    at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:264)
    at java.base/sun.security.ssl.SSLSocketImpl.handleException(SSLSocketImpl.java:1306)
    at java.base/sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:832)
    at okio.Okio$2.read(Okio.java:138)
    at okio.AsyncTimeout$2.read(AsyncTimeout.java:236)
    ... 28 more
Caused by: java.net.SocketException: Socket closed
    at java.base/java.net.SocketInputStream.read(SocketInputStream.java:183)
    at java.base/java.net.SocketInputStream.read(SocketInputStream.java:140)
    at java.base/sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:448)
    at java.base/sun.security.ssl.SSLSocketInputRecord.bytesInCompletePacket(SSLSocketInputRecord.java:68)
    at java.base/sun.security.ssl.SSLSocketImpl.readApplicationRecord(SSLSocketImpl.java:1096)
    at java.base/sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:816)
    ... 30 more
ResponseError. Reason: java.net.SocketTimeoutException: timeout, Response:
 

jtare

Active Member
Licensed User
Longtime User
Now I understand the question. One possible solution is to set the timeout to be high enough so it will rarely happen.

You cannot suppress these logs.
Thanks. Will try it and see how it goes.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…