问题
我有一个post请求是只有当数据恢复是很长的时间(大约60Mb的JSON格式的数据)导致错误。
相同的请求与较less的信息不会导致任何错误,它的作品完美。
总是出现在正好2分钟的错误信息提出要求,是如下:
java.io.EOFException at com.android.okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:98) at com.android.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:202) at com.android.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:119) at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:798) at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:405) at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:349) at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:517) at com.android.okhttp.internal.http.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105) at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:25) at com.myproject.mypackage.DataManagerService$ServiceHandler.sincronitzar_baixada_dades(DataManagerService.java:1406) at com.myproject.mypackage.DataManagerService$ServiceHandler.handleMessage(DataManagerService.java:403) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.os.HandlerThread.run(HandlerThread.java:61)
在服务器端,我们发现在我的设备发生错误后,服务正在准备数据仍然活着。
几天前,我们增加了服务器上的RAM,以避免在同一个琐事中出现OOM错误。
更多代码更新03/06/2016
还附加了发出请求的代码并将响应保存在设备上的一个文件中:
请求码:
HttpsURLConnection con = (HttpsURLConnection) Https_url.openConnection(); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1){ con.setRequestProperty("Connection", "close"); } con.setReadTimeout(DEFAULT_RESPONSE_TIMEOUT); con.setConnectTimeout(DEFAULT_RESPONSE_TIMEOUT); con.setRequestMethod("POST"); con.setRequestProperty("Accept-Encoding","identity"); con.setDoInput(true); con.setDoOutput(true); con.connect(); int status = con.getResponseCode(); if (status >= 400) { inputStreamPujada = con.getErrorStream(); } else{ inputStreamPujada = con.getInputStream(); } if (inputStreamPujada != null){ try { OutputStream out = new FileOutputStream(file); byte[] buf = new byte[1024]; int len; while((len=in.read(buf))>0){ <--// THIS LINE IS THROWING EOFExceptiono error! out.write(buf,0,len); } out.close(); in.close(); } catch (Exception e) { e.printStackTrace(); } }
我们尝试了什么?
问题
这个EOFException的原因是什么? 为什么要使用低数据并将其投入大数据? 这是一些引渡超时或图书馆限制在2分钟内的最长时间?
提前致谢!
经过大量的研究,我们修改了服务器端发送5000个记录的分页系统中的数据量, 每次刷新 JSON文件。
看起来,服务器被寻址数据阻塞,并使请求以EOFException结束,如问题所示。
我希望这个问题有一天会对别人有用。 谢谢!