android - Httpclient execute always fails after second time (IOExpception, socket timeout) -


anyone sees reason? there doesn't seem problems server, can send curl requests time. socket timeout exception after second time try query server. if restart application starts working first time , stops.

 string params = string.format(params);     httpparams httpparameters = new basichttpparams();     defaulthttpclient httpclient = new defaulthttpclient(httpparameters);     int connectiontimeout = 1000;     httpconnectionparams.setconnectiontimeout(httpparameters, connectiontimeout);     int sockettimeout = 1000;     httpconnectionparams.setsotimeout(httpparameters, sockettimeout);      httppost httppost = new httppost("http://example.com");     httppost.setheader("content-type", "application/json");     httppost.addheader("cookie", cookie);;      try {         httppost.setentity(new stringentity(parameters, "utf-8"));     } catch (unsupportedencodingexception e) {         return ("error_unsupportedencodingexception");     }     inputstream inputstream = null;     string stream = null;      try {         httpresponse response = httpclient.execute(httppost);         httpentity entity = response.getentity();         inputstream = entity.getcontent();          bufferedreader reader = new bufferedreader(new inputstreamreader(inputstream, "utf-8"), 8);         stringbuilder a= new stringbuilder();          string line = null;          while ((line = reader.readline()) != null) {             a.append(line + "\n");         }          stream = a.tostring();          if (inputstream != null) {             inputstream.close();         }     } catch (unsupportedencodingexception e) {         return ("error_unsupportedencodingexception");     } catch (clientprotocolexception e) {         return ("error_clientprotocolexception");     } catch (ioexception e) {         return ("error_ioexception");     } 


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -