Retrofit network calls fails with a Protocol Exception suddenly in a working app. The app was working till yesterday and today all the network calls fails. The calls works fine with HTTP and with some HTTPS except my production endpoint.
It seems that app is not working only on my used https endpoint but working with other https endpoint, I tried.
I fixed the problem this way -
OkHttpClient client = new OkHttpClient();
client.setProtocols(Arrays.asList(Protocol.HTTP_1_1));
And
And my problem solved and except this after upgrading my used library okhttp2 to okhttp3 also working fine with same https endpoint.
- I don't understand what can be the real cause?
- And if it's problem with okhttp2 then why it was working recently?
- And why it's problem on a specific endpoint and working fine for some endponits?
I followed this and this link but still I don't understand whats the real problem.
Note 1: - This is working fine in Samsung S4 (Android verison 4.4.2) device. and in logs showing "OkHttp-Selected-Protocol: http/1.1" but it's not working in Android 5.1.1, 6.0.1, 7.1 & Android 8.1.0
Note 2: - It was working perfectly without setting any explicitly HTTP1.1 protocol but it suddenly stopped working (in device 5.1.1, 6.0.1, 7.1 & Android 8.1.0).
Here is the logs,
java.net.ProtocolException: Expected ':status' header not present at
com.squareup.okhttp.internal.http.SpdyTransport.readNameValueBlock(SpdyTransport.java:197)at com.squareup.okhttp.internal.http.SpdyTransport.readResponseHeaders(SpdyTransport.java:104)
at com.squareup.okhttp.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:917)
at com.squareup.okhttp.internal.http.HttpEngine.access$300(HttpEngine.java:95)
at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:902)
at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:760)
at com.squareup.okhttp.Call.getResponse(Call.java:274)
at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:230)
at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:201)
at com.squareup.okhttp.Call.execute(Call.java:81)
at retrofit.client.OkClient.execute(OkClient.java:53)
at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:326)
at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220)
at retrofit.RestAdapter$RestHandler$2.obtainResponse(RestAdapter.java:278)
at retrofit.CallbackRunnable.run(CallbackRunnable.java:42)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at retrofit.Platform$Android$2$1.run(Platform.java:142)
at java.lang.Thread.run(Thread.java:818)