I think I'm experiencing that - it's an Android 1.5 SDK. I have to call multiple times under the code with the same URL (which is in a method) and it fails reliably.
When this fails, there is no exception, the stream is empty, so readConnection fails, and getResponseCode returns 1. Global caching is disabled, setDefaultUseCaches (wrong);
I think there should be any URL connection object pool.
How can I do this but any thoughts?
HttpURL Connection Connection = Faucet; {Url url = try new URL (this.url); Connection = (HttpURL connection) url.openConnection (); Connection.setRequestProperty ("Authorization", "Basic" + Base64Coder.encodeString (user + ":" + password)); Connection.setRequestProperty ("User-agent", User Agent); Connection.connect (); ReadConnection (connection.getInputStream ()); Connection.disconnect (); } Hold (IOException pre) {reportException (formerly, connection.getResponseCode ())} hold (parser extension) {reportException (formerly, connection.getResponseCode ())}
The way I fixed this problem, it was to add the bottom line ...
System.setProperty ("Http. KeepAlive", "wrong");
... before my connection line ...
connection = (HttpURLConnection) url.openConnection ();
Good luck!
Comments
Post a Comment