My program is reading this large gzip file and it runs for an hour and so and it fails with the following stack trace:
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:196)
at java.net.SocketInputStream.read(SocketInputStream.java:122)
at sun.security.ssl.InputRecord.readFully(InputRecord.java:442)
at sun.security.ssl.InputRecord.read(InputRecord.java:480)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:927)
at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:884)
at sun.security.ssl.AppInputStream.read(AppInputStream.java:102)
at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:166)
at org.apache.http.impl.io.SocketInputBuffer.fillBuffer(SocketInputBuffer.java:90)
at org.apache.http.impl.io.AbstractSessionInputBuffer.read(AbstractSessionInputBuffer.java:212)
at org.apache.http.impl.conn.LoggingSessionInputBuffer.read(LoggingSessionInputBuffer.java:82)
at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:182)
at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:138)
at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:238)
at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
at java.util.zip.GZIPInputStream.read(GZIPInputStream.java:116)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177)
at java.io.InputStreamReader.read(InputStreamReader.java:184)
at java.io.BufferedReader.fill(BufferedReader.java:154)
at java.io.BufferedReader.readLine(BufferedReader.java:317)
at java.io.BufferedReader.readLine(BufferedReader.java:382)
at com.trainchaser.feed.connections.StaticConnect.getScheduleFile(StaticConnect.java:116)
at com.trainchaser.app.App.main(App.java:32)
where line StaticConnect.getScheduleFile(StaticConnect.java:116)
is the while loop in the code below.
I've read similar posts and I do close the reader (in
) after its done reading the while loop but it was still giving me the same error. So I think maybe if I consume the entity it would work, like so:
HttpEntity entity=getResponse.getEntity();
BufferedReader in = new BufferedReader(new InputStreamReader(
new GZIPInputStream(entity.getContent())));
EntityUtils.consumeQuietly(entity);
try
{
while ((content = in.readLine()) != null)
{...
Would that work? I was thinking maybe if I store the gzip file temporarily and not having the connection still allocated continuously would help prevent the error. I would test it myself but I am currently testing the fix of turning off firewall to see if it still errors out.
I am using org.apache.http.HttpEntity
if it helps