getting issue when writing large video file using httpurlconnection.
java.io.ioexception: unexpected end of stream on connection{192.1.4.55, proxy=direct@ hostaddress=192.1.4.55 ciphersuite=none protocol=http/1.1} (recycle count=0) w/system.err: @ com.android.okhttp.internal.http.httpconnection.readresponse(httpconnection.java:210)w/system.err: @ com.android.okhttp.internal.http.httptransport.readresponseheaders(httptransport.java:80) w/system.err: @ com.android.okhttp.internal.http.httpengine.readnetworkresponse(httpengine.java:904) w/system.err: @ com.android.okhttp.internal.http.httpengine.readresponse(httpengine.java:788) @ com.android.okhttp.internal.huc.httpurlconnectionimpl.execute(httpurlconnectionimpl.java:443) @ com.android.okhttp.internal.huc.httpurlconnectionimpl.getresponse(httpurlconnectionimpl.java:388) @ com.android.okhttp.internal.huc.httpurlconnectionimpl.getresponsecode(httpurlconnectionimpl.java:501)
response code here
final inputstream = connection.getinputstream(); final bytearrayoutputstream bytes = new bytearrayoutputstream(); final byte[] buffer = new byte[maxbuffersize]; int bytesread; while ((bytesread = is.read(buffer, 0, 1024)) != -1) { bytes.write(buffer, 0, bytesread); } log.log(info, format("{0} took {4} ms", url, (currenttimemillis() - start))); string response = new string(bytes.tobytearray());
check if using okhttpclient, here parameter retryonconnectionfailure(false). default false, make true error removed. because have same problem , solve change it.
okhttpclient client = new okhttpclient.builder() .retryonconnectionfailure(true) .build();
Comments
Post a Comment