EOF Exception Android API 14+ , URLConnection
See original GitHub issueFrom chris.mark.jenkins@gmail.com on March 27, 2013 08:55:20
Version of google-http-java-client (e.g. 1.5.0-beta)? 1.13.1-beta Java environment (e.g. Java 6, Android 2.3, App Engine)? Java 6, Android 4.X (Galaxy Nexus, Nexus 4, Nexus 7, Samsung S2) (Real devices NOT AVD). Describe the problem. Connection spoiling the header by leaving an old connection open. See attached forum post: https://groups.google.com/forum/?fromgroups=#!topic/android-developers/e_FExl6jl90 This is a sporadic bug, but “looks” like the connection terminated the connection randomly when it appears that the old connection is not “cleaned” properly. How would you expect it to be fixed? As mentioned in the forum post I am fixing the request with the following method when creating the request.
public static void tryToFixNetHttpRequest(final HttpHeaders headers)
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
try
{
headers.set("Connection", "close");
}
catch (Exception e)
{
}
}
So far I am yet to see the error again. We can of course use this as a work around on android, but a better solution would be more appropriate.
_Original issue: http://code.google.com/p/google-http-java-client/issues/detail?id=213_
Issue Analytics
- State:
- Created 9 years ago
- Comments:12 (9 by maintainers)

Top Related StackOverflow Question
From james.w…@gmail.com on May 21, 2014 18:14:31
I was able to work around this problem using a retry mechanism. The trick is to ensure that the number of retries corresponds with the “http.maxConnections” system property. I shared the code here: http://stackoverflow.com/a/23795099/204480
This issue is super old. I’m going to close this. If someone comes along, and sees this, please open a new issue.