4

My Android application uses URLConnection to connect to a webservice. It's in the market over a year now and works quite well. However, problems with Galaxy Nexus users came up recently:

When getting the input stream (not even reading yet!) from the URLConnection like:

final BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream()), 8192);

A EOFException is thrown at getInputStream().

First I thought this may be an ICS problem, so I installed an early build on my Nexus S, but there I couldn't reproduce the problem. Then I got access to a Galaxy Nexus, which crashes in the same way as the bug reports I've received, which makes me believe that it's probably not a case of a single phone acting weird.

The stack trace of the crash can be seen here and the whole code on GitHub. It's really weird, the app has some 100k+ installations on Android Market and the problem only seem to occur on the Galaxy Nexus.

Any hints or suggestions would be greatly appreciated!

phreezie
  • 324
  • 2
  • 8

2 Answers2

6

I'm seeing this same error on ICS, I "fixed" it by disabling keepAlive:

    System.setProperty("http.keepAlive", "false");
Darrell
  • 1,945
  • 15
  • 21
0

I've seen the same issue on my Xperia Arc S (Note! Non-ICS) during development of my app. I'm almost certain that we see the same symptom of two different problems, though.

In my case I was reading the entire stream as a UTF8 String but the server side implementation was expecting me to read the first byte as a numeric byte and the rest of it as UTF8 String.

I'm not sure on the details for why I really got an EOFException, but reading the stream, paying attention to the types in the custom protocol in it, solved my problem.

dbm
  • 10,376
  • 6
  • 44
  • 56
  • 1
    Thanks! There are some more hints at the bug tracker on Google Code. Will let you know how it turns out. – phreezie Dec 28 '11 at 09:12
  • 1
    Actually, the server I was connecting to didn't send the "Connection: close" header. Adding it explicitly to the client header solved the problem. – phreezie Dec 30 '11 at 09:11
  • Ahh! What a bastard (the server, that is). I have to check if this might also be the root cause for my symptoms. Great work on tracking this bug, and thanks for sharing! – dbm Dec 30 '11 at 09:36
  • Indeed. It's fixed now on server side too, so problems concerning that one should disappear soon. :) – phreezie Jan 03 '12 at 15:12