B4J Question Http client - Too many follow-up requests: 21

lancaster

Member
Licensed User
Longtime User
When performing a simple GET to a remote host, I get the following. My code has been used many times before with other remote sites. Constructing the identical request in PostMan works fine. Any idea what is causing this?

(Http client initialized with accept all option.)
java.net.ProtocolException: Too many follow-up requests: 21
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:127)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154)
at anywheresoftware.b4h.okhttp.OkHttpClientWrapper.executeWithTimeout(OkHttpClientWrapper.java:175)
at anywheresoftware.b4h.okhttp.OkHttpClientWrapper.access$0(OkHttpClientWrapper.java:172)
at anywheresoftware.b4h.okhttp.OkHttpClientWrapper$ExecuteHelper.run(OkHttpClientWrapper.java:220)
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)

Thanks in advance for any wisdom.
 

jahswant

Well-Known Member
Licensed User
Longtime User
Jake Wharton wrote:

This gets thrown (by OkHttp, not Retrofit) when there are more than 20 redirects when calling an endpoint. Usually this indicates a redirect cycle between two endpoints. Both Chrome and Firefox will also stop loading the request after this many redirects and fail the request.
You need to consult with your server team or endpoint documentation to ensure you are passing the correct data directly to the endpoint you want to call. No action for Retrofit to take here.
And rest of the thread is there:https://github.com/square/retrofit/issues/1561
 
Upvote 0

Hamied Abou Hulaikah

Well-Known Member
Licensed User
Longtime User
It is more like a server side auhentication problem enter you in redirect loop.
Postman success, so check all headers are set and sent using okhttp properly.
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
Last edited:
Upvote 0

lancaster

Member
Licensed User
Longtime User
Thanks for the replies. My problem is fixed. My original code was emulating user login using name and password to a remote host. Someone there activated single sign on and so I was giving the (originally correct) input to the completely wrong dialog. Hence the flood of responses.
Hence the flood.

So the real answer was "You need to consult with your server team or endpoint documentation to ensure you are passing the correct data directly to the endpoint you want to call."

DoH! My bad. thanks again.
 
Upvote 0
Top