android - AsyncTask, network operations and timeouts -


i performing network operation, on asynctask;

try {                    int timeout = 5000;                  httpparameters = new basichttpparams();     httpconnectionparams.setconnectiontimeout(httpparameters, timeout);      client = new defaulthttpclient(httpparameters);     request = new httpget(url);      response = client.execute(request);     in = null;     in = new bufferedreader(new inputstreamreader(response.getentity().getcontent()));      line = in.readline(); } catch (exception e) {          return "error connecting server"; } 

i struggling timeouts, , slow connections.

if taking more 5 seconds retrieve data, getting timeout exception. understand if task not completed in 5 seconds timeout, if has contacted server, , downloading data takes more 5 seconds download.

i not wish set timeout 20 seconds long wait if there problem contacting server.

is there way should doing this, instead of using timeout?

it may understanding floored, , timeout ignored once server has been reached.

after server contacted, able read first portion of data immediately. line taking more 1 second transfer glitch. anyway, timeout not fire on connection activity, meant start ticking on stalled connections.

note 5-second timeout users experience relatively often, have handle condition correctly. debug branch executes on timeout, i'd suggest temporarily choose small timeout value reproduce exception.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -