Search code examples
androidloopj

loopj infinite loop when host not found


I am trying to make use of loopj's Async HTTP library, but I encountered quite critical problem. When I am making a request to a host that does not exist it goes into infinite loop.

I tried debugging the code, but I didn't find much:

  1. com.loopj.android.http.AsyncHttpRequest.run() runs and calls com.loopj.android.http.AsyncHttpRequest.makeRequestWithRetries()
  2. Then inside makeRequestWithRetries() com.loopj.android.http.AsyncHttpRequest.makeRequest() is called which throws ConnectTimeoutException that looks like it is being caught by IOException catch and com.loopj.android.http.RetryHandler.retryRequest(IOException, int, HttpContext) is called.
  3. Then I app is not caught in any previous breakpoints, not even com.loopj.android.http.AsyncHttpResponseHandler.handleMessage(Message) and no message is fired, it just gets stuck.

However I am able to cancel this request with com.loopj.android.http.AsyncHttpClient.cancelRequests(Context, boolean).

I have te newest possible code, because I got it yesterday from github and build myself.

I appreciate any help.


Solution

  • Mentioned this in a comment, but I was having the same issue, and can confirm that the latest version of the library fixes this issue.

    See this pull request: https://github.com/loopj/android-async-http/commit/87a615c3b86c3e33bd885435f98ab33483f874e9