Error de tiempo de espera al consumir el servicio web por primera vez en Android

I am working on application that consume webservice right away after start to fetch some basic data. When I go for "Clean Install" of new emulator, the application crashes as the web service consuming goes for timeout. But when the same code the same emulator I run right away it works fine and then every single time it's ok just the first run on "clean" emulator is having problem. Any suggestions, ideas why?

PS : Using .net webservice returning xml and ksoap2 on android to consume it.

Muchas Gracias

preguntado el 08 de noviembre de 11 a las 10:11

1 Respuestas

I am sure you need to setConnectionTimeout y setSoTimeout while making web request.

Por ejemplo:

HttpGet httpGet = new HttpGet(url);
HttpParams httpParameters = new BasicHttpParams();

// Set the timeout in milliseconds until a connection is established.
int timeoutConnection = 3000;
HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection);

// Set the default socket timeout (SO_TIMEOUT) 
// in milliseconds which is the timeout for waiting for data.
int timeoutSocket = 5000;
HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);

DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters);
HttpResponse response = httpClient.execute(httpGet);

respondido 08 nov., 11:14

hmm will try, should not this be set by default onto some rational values? - Alone89

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.