title: Why does not my HTTP Connection timeout?
body: <p>I have the following code for doing a HTTP Post: </p>
  
  <pre><code>InputStream ins = null;
  String result = null; 
  public String postforBakup(String url){
  
      java.util.Date date= new java.util.Date();
      Timestamp timestamp = (new Timestamp(date.getTime()));
  
  
  
      HttpParams httpParameters = new BasicHttpParams();
      int timeoutConnection = 3000;
      HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection);
      int timeoutSocket = 5000;
      HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);
  
  
      DefaultHttpClient http = new DefaultHttpClient(httpParameters); 
      HttpPost httppost = new HttpPost(url);
      httppost.setHeader("Accept", "application/json");
      httppost.setHeader("Content-Type", "application/x-www-form-urlencoded");
  
      try{
          JSONArray json = (makeJSON());
  
  
  
          List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(5);
          nameValuePairs.add(new BasicNameValuePair("key", processKey()));
          nameValuePairs.add(new BasicNameValuePair("type", "Android"));
          nameValuePairs.add(new BasicNameValuePair("timestamp", timestamp.toString()));
          nameValuePairs.add(new BasicNameValuePair("mail", mail));
          nameValuePairs.add(new BasicNameValuePair("jsonArray", Arrays.asList(json).toString()));
          httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
  
  
  
  
          HttpResponse resp = http.execute(httppost); 
          HttpEntity entity = resp.getEntity();
          ins = entity.getContent(); 
          BufferedReader bufread = new BufferedReader(new InputStreamReader(ins, "UTF-8"), 8); 
          StringBuilder sb = new StringBuilder(); 
          String line = null; 
          while((line = bufread.readLine()) != null){
              sb.append(line +"\n"); 
          }
          result = sb.toString().trim(); 
          System.out.println("Response: "+result);
  
  
  
  
      }catch (Exception e){
  
          System.out.println("Squish: "+e); 
  
      }finally{
          try{
              if(ins != null){
                  ins.close();
              }
          }catch(Exception smash){
              System.out.println("Squish: "+smash); 
          }
      }
      if(result.equalsIgnoreCase("Authentication failed")){
          System.out.println("Death");
          return "Backup failed"; 
      }else if (result.equalsIgnoreCase("update successfull")){
          System.out.println("Life");
          return "Success";
      }else{
          return "failed";
      }
  }
  </code></pre>
  
  <p>While as the function works properly if connected to WIFI, when I switch to 2g I get the loader for hours without any exception or a message of timeout. What is possibly wrong here? </p>