Volley + OkHttp on Android gives error in 200 status response

When I make my request only with Volley, everything goes well and my StringRequest goes to onResponse.

But when I switch to the Volley + Okhttp combination, my request passes, I get the same answer as before, but then I get the following error message:

E/VolleyοΉ• [122319] BasicNetwork.performRequest: Unexpected response code 200 for <my request url> java.io.IOException: closed com.android.volley.NetworkError: java.io.IOException: closed at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:182) at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:114) Caused by: java.io.IOException: closed at okio.RealBufferedSource$1.read(RealBufferedSource.java:345) at java.io.InputStream.read(InputStream.java:162) at com.android.volley.toolbox.BasicNetwork.entityToBytes(BasicNetwork.java:254) at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:130) at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:114)

Im using this https://gist.github.com/bryanstern/4e8f1cb5a8e14c202750 for my OkHttpStack for Volley.

+4
source share
2 answers

I did not have too much time to research, but I encountered the same problem when using an emulator connected through a proxy (Charles). For me, the problem goes away when I test without a proxy server or on a device.

+2
source

The same problem occurred when using the start and stop RequestQueue methods. Many popular blogs have indicated that RequestQueue should be stopped when the user throws so that there is no twitching. However, when you call stop, all RequestQueue requests are terminated, even those that are already making a network call. The above exception occurred when these requests were previously stopped. Do not call the stop function, solve the problem for me.

0
source

All Articles