title: SocketTimeOutException while sending a HttpPost request
body: <p>My application works with Facebook and does post requests with JSON params.
  Request is sent for ~ 7-8 minutes and then I catch a SocketTimeOutException.
  In 10 minutes I can send a request again.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>public static String httpTPRequest(String url, String params) {
      String response = Static.EMPTY;
      HttpPost httpPost = new HttpPost(url);
      httpPost.addHeader("Content-Type", "application/json");
      HttpParams httpParams = new BasicHttpParams();
      DefaultHttpClient httpClient = new DefaultHttpClient(httpParams);
      HttpConnectionParams.setConnectionTimeout(httpParams, HTTP_TIMEOUT);
      HttpConnectionParams.setSoTimeout(httpParams, HTTP_TIMEOUT);
  
      try {
          httpPost.setEntity(new StringEntity(params, "UTF-8"));
          HttpResponse httpResponse = httpClient.execute(httpPost);
          HttpEntity entity = httpResponse.getEntity();
          if (entity != null) {
              response = EntityUtils.toString(entity);
          }
      } catch (Exception e) {
          Debug.log(TAG, "tp server request:" + e.getMessage());
      }
  
      return response;
  }
  </code></pre>
  
  <p>Why it happens?</p>
  
  <p>Stack trace</p>
  
  <pre><code>SocketTimeoutException:Http::Socket stack:org.apache.harmony.luni.platform.OSNetworkSystem.connectStreamWithTimeoutSocketImpl(Native Method)
  Http::Socket stack: org.apache.harmony.luni.platform.OSNetworkSystem.connectStreamWithTimeoutSocket(OSNetworkSystem.java:131)
  Http::Socket stack: org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:247)
  Http::Socket stack: org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:535)
  Http::Socket stack: java.net.Socket.connect(Socket.java:1054)
  Http::Socket stack: org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:117)
  Http::Socket stack: org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:129)
  Http::Socket stack: org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
  Http::Socket stack: org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
  Http::Socket stack: org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:348)
  Http::Socket stack: org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
  Http::Socket stack: org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
  Http::Socket stack: org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
  Http::Socket stack: com.saymeow.saymeow.utils.Http.httpTPRequest(Http.java:194)
  Http::Socket stack: java.lang.Thread.run(Thread.java:1096)
  Http::Socket stack: com.saymeow.saymeow.requests.ApiRequest$1.run(ApiRequest.java:83)
  Http::SocketTimeoutException: Socket is not connected
  </code></pre>