Good noon everyone!
I am using Retrofit
for networking calls in my application. The app is really working fine with great speed. Thanks for the wonderful library. But, It is working only in wi-fi. If i run the app in 3G network, throwing the error. stream was reset: PROTOCOL_ERROR, while using Retrofit in 3G network
I have imported this jar files to the build path :
Here is the complete stack trace:
11-17 16:01:54.017: D/Retrofit(3595): java.io.IOException: stream was reset: PROTOCOL_ERROR
11-17 16:01:54.017: D/Retrofit(3595): at com.squareup.okhttp.internal.spdy.SpdyStream.getResponseHeaders(SpdyStream.java:146)
11-17 16:01:54.017: D/Retrofit(3595): at com.squareup.okhttp.internal.http.SpdyTransport.readResponseHeaders(SpdyTransport.java:109)
11-17 16:01:54.017: D/Retrofit(3595): at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:676)
11-17 16:01:54.017: D/Retrofit(3595): at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:426)
11-17 16:01:54.017: D/Retrofit(3595): at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:371)
11-17 16:01:54.017: D/Retrofit(3595): at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:466)
11-17 16:01:54.017: D/Retrofit(3595): at com.squareup.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)
11-17 16:01:54.017: D/Retrofit(3595): at com.squareup.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:25)
11-17 16:01:54.017: D/Retrofit(3595): at retrofit.client.UrlConnectionClient.readResponse(UrlConnectionClient.java:73)
11-17 16:01:54.017: D/Retrofit(3595): at retrofit.client.UrlConnectionClient.execute(UrlConnectionClient.java:38)
11-17 16:01:54.017: D/Retrofit(3595): at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:321)
11-17 16:01:54.017: D/Retrofit(3595): at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:240)
11-17 16:01:54.017: D/Retrofit(3595): at $Proxy0.getLoginCredentials(Native Method)
11-17 16:01:54.017: D/Retrofit(3595): at com.connected.merchant.SignIn$SignMeIn.doInBackground(SignIn.java:197)
11-17 16:01:54.017: D/Retrofit(3595): at com.connected.merchant.SignIn$SignMeIn.doInBackground(SignIn.java:1)
11-17 16:01:54.017: D/Retrofit(3595): at android.os.AsyncTask$2.call(AsyncTask.java:288)
11-17 16:01:54.017: D/Retrofit(3595): at java.util.concurrent.FutureTask.run(FutureTask.java:237)
11-17 16:01:54.017: D/Retrofit(3595): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
11-17 16:01:54.017: D/Retrofit(3595): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
11-17 16:01:54.017: D/Retrofit(3595): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
11-17 16:01:54.017: D/Retrofit(3595): at java.lang.Thread.run(Thread.java:841)
11-17 16:01:54.017: D/Retrofit(3595): ---- END ERROR
Google didn't help me. It would be really great if you help me to sort this out. Thanks.
I solved a similar problem by restricting the request to use HTTP 1, see:
OkHttpClient okHttpClient = new OkHttpClient();
okHttpClient.setProtocols(Arrays.asList(Protocol.HTTP_1_1));
Looks like a bug in either OkHtttp or your webserver's implementation of SPDY or HTTP/2. Upgrade to OkHttp/2.1. If that doesn't fix it, open an issue on OkHttp's issue tracker & include the hostname of the server that's causing you grief.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With