Note that there are some explanatory texts on larger screens.

plurals
  1. PONo IOException on Outputstream when dataconnection lost
    text
    copied!<p>I'm developing this android application which basically uploads images to a webservice. I have a asynctask where I send the file to the server, using this code:</p> <pre><code>protected Boolean doInBackground(byte[]... params) { HttpURLConnection connection = getConnection(); BufferedOutputStream out = new BufferedOutputStream(connection.getOutputStream()); Log.d("OutputStream", "stream created, about to write"); out.write(params[0]); Log.d("OutputStream", "all bytes written"); out.close(); } </code></pre> <p>Of course, this block of code is wrapped within a try catch, catching IOExceptions etc. The problem is that when I interrupt the connection <strong>after</strong> I see the first logtext, an exception is never thrown or only after a really long time (talking about 20 minutes or so), which doesn't make any sense at all.</p> <p>The HttpURLConnection is set up like this:</p> <pre><code>urlConnection = (HttpURLConnection) url.openConnection(); urlConnection.setRequestMethod("POST"); urlConnection.setRequestProperty("Content-Type", this.contentType); urlConnection.setRequestProperty("User-Agent", String.format("custom-user-agent/%d", R.integer.version_code)); urlConnection.addRequestProperty("SessionID", this.sessionID); urlConnection.setDoOutput(true); urlConnection.setConnectTimeout(30000); urlConnection.setReadTimeout(30000); urlConnection.setChunkedStreamingMode(0); urlConnection.setUseCaches(false); urlConnection.connect(); </code></pre> <p>Funny thing is, this only happens when interrupting a EDGE/3G connection. When I interrupt a wifi connection, the exception is thrown immediately (which, of course, is a lot more convenient). </p> <p>Any idea on this? </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload