title: Set Timeout on Asynchronous Http Client
body: <p>im using the Asynchronous Http Client that can be found here: <a href="http://loopj.com/android-async-http/" rel="nofollow noreferrer">http://loopj.com/android-async-http/</a> </p>
  
  <p>and it works great besides about 1 out of every 10 or so requests I make end up giving me a infinite progress dialog which I believe means for whatever reason no response of any kind is being returned because I have written code to dismiss the dialog in onSuccess AND onFailure so im a bit confused how this could happen. </p>
  
  <p>Here is my code that sets up the request:</p>
  
  <pre><code>  public static void post(String token,String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
       Log.i(token,"token");
        client.addHeader("token", token);
        client.setTimeout(3000);
        client.post(url, params, responseHandler);
  
  
    }
  </code></pre>
  
  <p>And here is where i override onSuccess and onFailure:</p>
  
  <pre><code>@Override
              public void onFailure(Throwable arg0, String arg1) {
                  // TODO Auto-generated method stub
                  super.onFailure(arg0, arg1);
                  pdialog.dismiss();
                  Log.i("failed to login", arg1.toString());
                  Toast.makeText(getActivity(), arg1.toString() , Toast.LENGTH_LONG).show();
              }
  
              @Override
              public void onSuccess(final JSONObject json) {
                  pdialog.dismiss();
      }
  </code></pre>