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!
我在ICS上看到同样的错误,我通过禁用keepAlive来“修复”它:
System.setProperty("http.keepAlive", "false");
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.