Issue 869 in google-api-java-client: EOFException when performing request

18 views
Skip to first unread message

google-api-...@googlecode.com

unread,
Apr 9, 2014, 4:02:10 PM4/9/14
to google-api-jav...@googlegroups.com
Status: New
Owner: wonder...@google.com
Labels: Type-Defect Priority-Medium

New issue 869 by davidpbr...@gmail.com: EOFException when performing request
http://code.google.com/p/google-api-java-client/issues/detail?id=869

Version of google-api-java-client : google-http-client-1.17.0-rc


Java environment: Android 4.3


Describe the problem.

During certain requests I receive the following:

04-09 12:52:31.937 I/ApiClient REQUEST: POST : /api/stream/start body:
{
"mediaType" : {
"parameters" : {
"charset" : "UTF-8"
},
"subType" : "x-www-form-urlencoded",
"type" : "application",
"charsetParameter" : "java.nio.charset.CharsetICU[UTF-8]"
},
"data" : {
"uuid" : "6ecd6zd8-0452-4ff9-96be-341d8168d7a9",
"private" : false,
"title" : "04/09/2014 12:52 PM",
"description" : "Example Description",
"extra_info" : "{'foo': 'bar'}"
},
"length" : 159,
"type" : "application/x-www-form-urlencoded; charset=UTF-8"
}
04-09 12:52:32.107 W/ApiClient Unhandled Error: java.io.EOFException
cannot be cast to com.google.api.client.http.HttpResponseException. Stack
trace follows:
04-09 12:52:32.107 W/System.err﹕ java.io.EOFException
04-09 12:52:32.117 W/System.err﹕ at
libcore.io.Streams.readAsciiLine(Streams.java:203)
04-09 12:52:32.117 W/System.err﹕ at
libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:579)
04-09 12:52:32.117 W/System.err﹕ at
libcore.net.http.HttpEngine.readResponse(HttpEngine.java:827)
04-09 12:52:32.127 W/System.err﹕ at
libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:283)
04-09 12:52:32.137 W/System.err﹕ at
libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:497)
04-09 12:52:32.147 W/System.err﹕ at
libcore.net.http.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:134)
04-09 12:52:32.147 W/System.err﹕ at
com.google.api.client.http.javanet.NetHttpResponse.<init>(NetHttpResponse.java:36)
04-09 12:52:32.147 W/System.err﹕ at
com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:94)
04-09 12:52:32.147 W/System.err﹕ at
com.google.api.client.http.HttpRequest.execute(HttpRequest.java:965)
04-09 12:52:32.157 W/System.err﹕ at
io.kickflip.sdk.api.KickflipApiClient.request(KickflipApiClient.java:367)
04-09 12:52:32.157 W/System.err﹕ at
io.kickflip.sdk.api.KickflipApiClient.access$300(KickflipApiClient.java:43)
04-09 12:52:32.157 W/System.err﹕ at
io.kickflip.sdk.api.KickflipApiClient$3.onSuccess(KickflipApiClient.java:342)
04-09 12:52:32.157 W/System.err﹕ at
io.kickflip.sdk.api.OAuthClient$1.run(OAuthClient.java:103)
04-09 12:52:32.157 W/System.err﹕ at
java.lang.Thread.run(Thread.java:841)

How would you expect it to be fixed?

Group consensus on StackOverflow seems to suggest this is due to connection
recycling. Setting a property on the HttpUrlConnection may address this
issue:

see
http://stackoverflow.com/questions/15411213/android-httpsurlconnection-eofexception



--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

google-api-...@googlecode.com

unread,
Dec 29, 2014, 5:19:17 PM12/29/14
to google-api-jav...@googlegroups.com
Updates:
Status: WontFix

Comment #1 on issue 869 by wonder...@google.com: EOFException when
performing request
https://code.google.com/p/google-api-java-client/issues/detail?id=869

This seems to only happen when using NetHttpTransport [1]. Since you are on
Android 4.3, you are recommended to use the ApacheHttpTransport, which you
should get by default if you call AndroidHttp.newCompatibleTransport() [2].
NetHttpTransport depends on the old javanet library and is less preferable
when other alternatives exist.

[1] http://stackoverflow.com/a/21618255/3882262
[2]
https://code.google.com/p/google-http-java-client/source/browse/google-http-client-android/src/main/java/com/google/api/client/extensions/android/http/AndroidHttp.java

google-api-...@googlecode.com

unread,
Jan 13, 2015, 3:46:51 PM1/13/15
to google-api-jav...@googlegroups.com

Comment #2 on issue 869 by davidpbr...@gmail.com: EOFException when
performing request
https://code.google.com/p/google-api-java-client/issues/detail?id=869

Appreciate the update.

If I read correctly, AndroidHttp.newCompatibleTransport() returns
NetHttpTransport, not ApacheHttpTransport if the Android API version
exceeds 9 (i.e 18 for Android 4.3).

public static HttpTransport newCompatibleTransport() {
return AndroidUtils.isMinimumSdkLevel(9) ? new NetHttpTransport() : new
ApacheHttpTransport();
}

[2] states:

There is no guarantee that Apache HTTP transport will continue to work in
future SDKs. Therefore, this method uses {@link NetHttpTransport} for
Gingerbread or higher, and otherwise {@link ApacheHttpTransport}.

To be crystal clear on Google's recommendation: Avoid NetHttpTransport in
all cases? Only where Android API < 9? Only where Android API < 18?

google-api-...@googlecode.com

unread,
Mar 1, 2015, 6:50:48 PM3/1/15
to google-api-jav...@googlegroups.com

Comment #3 on issue 869 by wonder...@google.com: EOFException when
performing request
https://code.google.com/p/google-api-java-client/issues/detail?id=869

Sorry I was mistaken. On platforms other than Android, ApacheHttpTransport
is preferred over NetHttpTransport. But Android doesn't seem to get along
with ApacheHttpTransport so you'd have to use NetHttpTransport. Plus,
Android's HttpUrlConnection's implementation is better than JDK's so it's
not too bad.

Using NetHttpTransport, you can manipulate request properties by overriding
ConnectionFactory#openConnection(URL), in which you open a connection and
set the property before returning.

https://github.com/google/google-http-java-client/blob/master/google-http-client/src/main/java/com/google/api/client/http/javanet/ConnectionFactory.java
Reply all
Reply to author
Forward
0 new messages