Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android HttpURLConnection throwing EOFException

Here's the question in simplest way.

I create a HTTPS connection to my server through proxy using HttpUrlConnection Object.

My proxy closes the connection but my code still tries to reuse the same connection. And so I get EOFException.

How do I handle such cases?

like image 381
Sudarshan Bhat Avatar asked Sep 07 '12 13:09

Sudarshan Bhat


Video Answer


1 Answers

I'd recommend disabling the http.keepalive system property. The performance section of the documentation indicates that socket connections will be reused when possible. It sounds like it is trying to reuse the connection, but the proxy has already closed it. On this post, Darrell also indicates that changing the system property solved his problem.

System.setProperty("http.keepAlive", "false");
like image 96
kturney Avatar answered Oct 21 '22 03:10

kturney