2017-09-07 4 views
0

Im Versuch, Daten von meinem Server mit Android 8 (26 Oreo) und ich erhalte die folgenden Fehler zu holen:Retrofit + OkHttp - Protocol

java.net.ProtocolException: unexpected end of stream 

Im mit Retrofit 2.3.0 OkHttp 3.9.0. Die seltsame Sache ist, dass dieser Fehler nur auf API 26 Oreo und nicht auf irgendwelchen vorherigen APIs auftritt, bekomme ich diesen Fehler zufällig, manchmal ja, manchmal nicht. Der Fehler ist aufgrund der Debugging-Funktionen von RxJava kurz.

EDIT: Ich änderte RxJava mit einer einfachen Anruf "Anfrage", das ist der vollständige Fehler:

java.net.ProtocolException: unexpected end of stream 
at okhttp3.internal.http1.Http1Codec$FixedLengthSource.read(Http1Codec.java:398) 
at okio.RealBufferedSource.readAll(RealBufferedSource.java:163) 
at retrofit2.Utils.buffer(Utils.java:304) 
at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:204) 
at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:112) 
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:153) 
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) 
at java.lang.Thread.run(Thread.java:764) 

Der Aufruf, die ich mache, ist ziemlich Standard:

TestInterface api = retrofit.create(TestInterface.class); 
      Call<List<Post>> call = api.getFeed(0, 0, "9"); 
      call.enqueue(new Callback<List<Post>>() { 
       @Override 
       public void onResponse(Call<List<Post>> call, Response<List<Post>> response) { 
        Log.i(TAG, "[app] onResponse"); 
       } 

       @Override 
       public void onFailure(Call<List<Post>> call, Throwable t) { 
        Log.i(TAG, "[app] onFailure: ", t); 
       } 
      }); 

Das ist meine Antwort Kopfzeilen, habe ich die Inhaltslänge überprüft und es stimmt mit meiner Antwort überein:

Allow →GET, HEAD, OPTIONS 
Connection →close 
Content-Language →en 
Content-Length →3277 
Content-Type →application/json 
Date →Sat, 09 Sep 2017 14:58:38 GMT 
Server →gunicorn/19.7.0 
Vary →Accept, Accept-Language, Cookie 
X-Frame-Options →SAMEORIGIN 

Antwort

-1

Dies ist ein Problem mit 2.3 0,0

Herunterstufung auf Version 2.1.0 Kompilierung 'com.squareup.retrofit2: Wandler-Gson: 2.1.0'

+0

Dank wird es versuchen! – box

+0

Nicht funktioniert .... – box

Verwandte Themen