Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Volley + OkHttp on Android gives error on status 200 response

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

But when I switch to Volley + Okhttp combination, my request goes through, I receive the same response 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.

like image 650
Kshitij Aggarwal Avatar asked Oct 31 '22 21:10

Kshitij Aggarwal


1 Answers

I haven't had too much time to investigate but I was running into the same issue when using the emulator connected through a proxy (Charles). For me the problem goes away when I test without a proxy or on device.

like image 107
user3062722 Avatar answered Nov 15 '22 04:11

user3062722