title: Async-http often hangs.
body: <p>I start a ProgressDialog when I start my async request and on seemingly random occasions the dialogue does not dismiss (code does not fire onSuccess or onFailure). I handle both possible success responses from the server (one of which is an error) and I have a failure block so in theory the ProgressDialog should always dismiss. Can someone tell what event I am missing? Or is there a better structure?</p>
  
  <p>My code structure:</p>
  
  <ol>
  <li>I have a Gateway class that handles all the networking</li>
  <li>The calling calls handles the .show() and .dismiss() events for the dialog</li>
  </ol>
  
  <p>Gateway:</p>
  
  <pre><code>public static void post(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
      client.post(getAbsoluteUrl(url), params, responseHandler);
  }
  
  public static void loadItems(final ItemAdapter itemAdapter, int itemID) {
  
      final String url = String.format(Constants.URL_ITEMS, itemID);
  
      post(url, null, new JsonHttpResponseHandler() {
  
          @Override
          public void onSuccess(JSONObject response) {
  
              try {
                  if (!response.isNull("items")) {
  
                      itemAdapter.updateData(items);
  
                  } else if (!response.isNull("error")) {
  
                     itemAdapter.signalError(response.getString("error"));
  
                  }
  
              } catch (JSONException e) {
                  itemAdapter.signalError("An unknown error has occurred");
                  e.printStackTrace();
              }
  
  
          }
          @Override
          public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error)
          {
              if (error instanceof SocketTimeoutException || error instanceof ConnectTimeoutException) {
                  itemAdapter.signalError("Connection timeout! Please check that you are connected to the internet");
              } else {
                  itemAdapter.signalError("An unknown error has occurred");
              }
          }
  
      });
  
  }
  </code></pre>
  
  <p>The adapter:</p>
  
  <pre><code>public ItemAdapter(Context context, int itemID) {
  
      progressDialog = ProgressDialog.show(context, "Items",
              "Loading items", true);
      Gateway.loadItems(this, itemID);
  
  
  }
  
  public void updateData(ArrayList&lt;Items&gt; items) {
      progressDialog.dismiss();
      this.items = items;
      notifyDataSetChanged();
  }
  
  public void signalError(String errorMessage) {
  
      progressDialog.dismiss();
  
      AlertDialog.Builder builder = new AlertDialog.Builder(context);
      builder.setTitle("Error")
              .setMessage(errorMessage)
              .setNegativeButton("OK", null).show();
  
  }
  </code></pre>