4

I am using google cloud enpoints in my android app. When I do a post call to my backend, I sometimes see an EOFException. This does not happen always. I get this error for 5% of my requests. Also, this varies on devices. Some devices show this error more times than others. Is this a bug? Is there a workaround for this issue?

These are the jars being used by the cloud point,

google-api-client-1.14.1-beta.jar
google-api-client-android-1.14.1-beta.jar
google-http-client-1.14.1-beta.jar
google-http-client-android-1.14.1-beta.jar
google-http-client-gson-1.14.1-beta.jar
google-oauth-client-1.14.1-beta.jar

Stacktrace

06-10 03:53:45.057: W/System.err(1460):     at android.os.AsyncTask$2.call(AsyncTask.java:287)
06-10 03:53:45.057: W/System.err(1460):     at java.util.concurrent.FutureTask.run(FutureTask.java:234)
06-10 03:53:45.057: W/System.err(1460):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
06-10 03:53:45.057: W/System.err(1460):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
06-10 03:53:45.057: W/System.err(1460):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
06-10 03:53:45.057: W/System.err(1460):     at java.lang.Thread.run(Thread.java:856)
06-10 03:53:45.107: W/System.err(1460): Caused by: java.io.EOFException
06-10 03:53:45.167: W/System.err(1460):     at libcore.io.Streams.readAsciiLine(Streams.java:203)
06-10 03:53:45.197: W/System.err(1460):     at libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:573)
06-10 03:53:45.288: W/System.err(1460):     at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:821)
06-10 03:53:45.297: W/System.err(1460):     at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:283)
06-10 03:53:45.397: W/System.err(1460):     at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:495)
06-10 03:53:45.677: W/System.err(1460):     at libcore.net.http.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:134)
06-10 03:53:46.037: W/System.err(1460):     at com.google.api.client.http.javanet.NetHttpResponse.<init>(NetHttpResponse.java:37)
06-10 03:53:46.057: W/System.err(1460):     at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:95)
06-10 03:53:46.057: W/System.err(1460):     at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:980)
06-10 03:53:46.097: W/System.err(1460):     at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:412)
06-10 03:53:46.198: W/System.err(1460):     at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:345)
06-10 03:53:46.198: W/System.err(1460):     at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:463)
06-10 03:53:46.247: W/System.err(1460):     at com.androidapp.android.ServerUtilities.postMessage(ServerUtilities.java:154)

Update all my jars to latest,

google-api-client-1.15.0-rc.jar
google-api-client-android-1.15.0-rc.jar
google-http-client-1.15.0-rc.jar
google-http-client-android-1.15.0-rc.jar
google-http-client-gson-1.15.0-rc.jar
google-oauth-client-1.15.0-rc.jar

Still face the same error,

Also, tried settting

System.setProperty("http.keepAlive", "false");

The error does not go away.

plspl
  • 728
  • 12
  • 26
  • Found a similar issue with EOFException, http://stackoverflow.com/questions/16410456/google-cloud-endpoint-keeps-throwing-unexpected-end-of-stream-exception. But the stacktrace looks a bit different. – plspl Jun 10 '13 at 04:15
  • google code issue - https://code.google.com/p/google-http-java-client/issues/detail?id=230 – plspl Jun 10 '13 at 04:36
  • Does http://stackoverflow.com/a/17791819/758458 help you? – howettl Jul 24 '13 at 23:33

1 Answers1

0

I get the same error however with another third party OAuth2 provider. I switched to use ApacheHttpTransport and the issue is gone.

Phuah Yee Keat
  • 1,572
  • 1
  • 17
  • 17
  • Are you using post Gingerbread version ? Prior to changing the HttpTransport Have you used AndroidHttp.newCompatibleTransport() which returned NetHttpTransport ? – AsafK Feb 07 '14 at 22:44