B4J Question HTTP request Error "Unexpected status line:"

nesam

Member
Licensed User
Longtime User
Hi
With 3 software servers there is no error, only with a hardware device.
But if I send the same request with POSTMAN, the device works without error. I followed the communication via Wireshark and there is nothing suspicious.
A simple POST request, but like losing the answer. Sometimes the request passes but an error still occurs.

B4X:
    Private x as string
    x=...     (JSON request)
    Dim j As HttpJob
    j.Initialize("", Me)
   
    j.PostString("http://192.168.1.7:8086/api/v3/invoices",  x)
    j.GetRequest.SetHeader("Accept","application/json")    'j.GetRequest.SetHeader("Accept","*/*")
    j.GetRequest.SetContentType("application/json")
   
    Wait For (j) JobDone (j As HttpJob)
       
    If j.Success Then ....

I tried to add: j.GetRequest.SetHeader ("Connection", "close") but not working.


error:
http://192.168.1.7:8086/api/v3/invoices
java.net.ProtocolException: Unexpected status line:
        at b4j/okhttp3.internal.http.StatusLine.parse(Unknown Source)
        at b4j/okhttp3.internal.http1.Http1Codec.readResponseHeaders(Unknown Source)
        at b4j/okhttp3.internal.http.CallServerInterceptor.intercept(Unknown Source)
        at b4j/okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source)
        at b4j/okhttp3.internal.connection.ConnectInterceptor.intercept(Unknown Source)
        at b4j/okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source)
        at b4j/okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source)
        at b4j/okhttp3.internal.cache.CacheInterceptor.intercept(Unknown Source)

        at b4j/okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source)
        at b4j/okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source)
        at b4j/okhttp3.internal.http.BridgeInterceptor.intercept(Unknown Source)

        at b4j/okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source)
        at b4j/okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(Unknown Source)
        at b4j/okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source)
        at b4j/okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source)
        at b4j/okhttp3.RealCall.getResponseWithInterceptorChain(Unknown Source)
        at b4j/okhttp3.RealCall.execute(Unknown Source)
        at b4j/anywheresoftware.b4h.okhttp.OkHttpClientWrapper.executeWithTimeout(Unknown Source)
        at b4j/anywheresoftware.b4h.okhttp.OkHttpClientWrapper.access$0(UnknownSource)
        at b4j/anywheresoftware.b4h.okhttp.OkHttpClientWrapper$ExecuteHelper.run(Unknown Source)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
        at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.base/java.lang.Thread.run(Unknown Source)
ResponseError. Reason: java.net.ProtocolException: Unexpected status line: , Response:
 
Last edited:
Top