title: CustomHttpClient.executeHttpPost giving ConnectTimeoutException
body: <h2>I have some problems with the timeout when requesting my login.php</h2>
  
  <blockquote>
    <p>02-10 20:23:26.361: V/(1084): org.apache.http.conn.ConnectTimeoutException: Connect to /10.0.2.2:8082 timed out</p>
  </blockquote>
  
  <ul>
  <li>I'm very similar to this one (http://stackoverflow.com/questions/8435535/android-and-php-login-authentication) but additionally i add some snippets from my code now.</li>
  </ul>
  
  <h2>LoginActivity.java</h2>
  
  <pre><code>response = CustomHttpClient.executeHttpPost("http://10.0.2.2:8082/login/login.php",postParameters); 
  </code></pre>
  
  <p>In the <i>CustomHttpClient.java</i> I get the timeout after the execute at the end. </p>
  
  <pre><code>HttpClient client = getHttpClient();
  HttpPost request = new HttpPost(url);
  UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(postParameters);
  request.setEntity(formEntity);
  HttpResponse response = client.execute(request);
  </code></pre>
  
  <p>The timeout comes after 5 seconds cause I used</p>
  
  <pre><code>public static final int HTTP_TIMEOUT = 5 * 1000; 
  private static HttpClient getHttpClient() {
          if (mHttpClient == null) {
              mHttpClient = new DefaultHttpClient();
              final HttpParams params = mHttpClient.getParams();
              HttpConnectionParams.setConnectionTimeout(params, HTTP_TIMEOUT);
              HttpConnectionParams.setSoTimeout(params, HTTP_TIMEOUT);
              ConnManagerParams.setTimeout(params, HTTP_TIMEOUT);
          }
          return mHttpClient;
      }
  </code></pre>
  
  <p>in the executeHttpPost method</p>
  
  <h2>My login.php looks like this.</h2>
  
  <pre><code>&lt;?php
  $hostname = 'localhost';
  $username = 'root';
  $pws = 'test';
  
  try {
      $name = $_POST['name'];
      $pw = $_POST['pw'];
  
      $dbh = new PDO("mysql:host=$hostname;dbname=toDoList", $username, $pws);
  
      $stmt = $dbh-&gt;prepare("SELECT * FROM account WHERE name = '$name'");
      $stmt-&gt;execute();
  
      $result = $stmt-&gt;fetchAll();
  
      foreach($result as $row)
          {
              echo ($pw == $row['password'] ? '1' : '0');
          }
  
      }
          catch(PDOException $e)
      {
      echo $e-&gt;getMessage();
      }
  ?&gt;
  </code></pre>