I see that your code doesn't have a call to: HttpConnectionParams.setSoTimeout
Have you tried adding that? 26 января 2012 г. 23:42 пользователь Madhu <[email protected]> написал: > Hi all, > > This is a really strange problem i have. I get JSON data from a server > through the DefaultHttpClient. I have even set the timeout to 10 > seconds and i have caught all exceptions. My doGet function works > great on all devices on various carriers. But i tried a device with > sprint 3g connection and also a verizon device with 3g connection. The > httprequest does not even timeout. After about 15 mins i received a > ConnectException. Please help me figure how i can fix this . Below is > my doGet for the RestClient. > I am surprised the connectionTimeout doesnt work and then i dont even > receive a response till about 15 mins and its a connectException. > Connection to the url refused. > > The same http request works fine on the browser as well even on the > device's browser. Only on certain devices and on 3g am seeing this > issue. > > > P.S: I have tried the HttpClient, DefaultHttpClient and even the > AndroidHttpClient and all of them give me the same result . > > public static void doGet(final String url, final IRequestCallBack > requestListner) { > Log.d(TAG, "RestClient: doGet: URL = " + url); > final DefaultHttpClient httpClient = new > DefaultHttpClient(); > > HttpConnectionParams.setConnectionTimeout(httpClient.getParams(), > 3000); > > Thread thread = new Thread() { > public void run() { > try { > > HttpGet httpget = new HttpGet(url); > HttpResponse response; > Log.i(TAG, "HIT EXECUTE OH > HTTPCLIENT"); > response = > httpClient.execute(httpget); > Log.v("response code", > response.getStatusLine() > .getStatusCode() + > ""); > HttpEntity entity = > response.getEntity(); > Log.i(TAG, "GOT rESPONSE "); > InputStream instream = > entity.getContent(); > String result = read(instream); > Log.d(TAG, result); > > requestListner.onResponseReceived(result); > } catch (Exception ex) { > requestListner.onError(ex); > } > } > }; > thread.start(); > } > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

