Hot questions for Handling ProtocolException in Retrofit

Top 10 Java Open Source / Retrofit / Handling ProtocolException

ProtocolException: Expected ':status' header not present

Question: 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 but fails with HTTPS.

Here is the logs,

java.net.ProtocolException: Expected ':status' header not present
10-18 14:59:01.103 30746-30746/? W/System.err:     at okhttp3.internal.http.Http2xStream.readHttp2HeadersList(Http2xStream.java:262)
10-18 14:59:01.103 30746-30746/? W/System.err:     at okhttp3.internal.http.Http2xStream.readResponseHeaders(Http2xStream.java:145)
10-18 14:59:01.103 30746-30746/? W/System.err:     at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:53)
...

Answer: Updating Retrofit and Okhttp3 libraries to the latest version did the trick for me.

compile 'com.squareup.okhttp3:okhttp:3.9.0'

compile 'com.squareup.retrofit2:retrofit:2.3.0'

The reason was in updating nginx on the server to the latest version (1.13.6). Ask your backend team if they did not update nginx on the server.