Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid HTTP Client freezes
    primarykey
    data
    text
    <p>I'm experiencing some odd behavior in my HTTP requests. I have some users that are saying that this call isn't ever coming back (the spinner marking it's asynchronous call never goes away). I have seen this happen before, but I attributed it to the emulator going through Charles Proxy. I haven't yet seen it on actual phone until now.</p> <p>I'm not sure what would cause this to happen, which is why I'm posting it here. Here's the call, using Jackson to deserialize the result into a Value Object. The two spots I saw the emulator freeze are httpclient.execute(httpGet); and getObjectMapper().readValue(jp, SyncVO.class);.</p> <p>While debugging, stepping over the offending statement caused the debugger to never gain control back of stepping. Meanwhile, I see the request go out AND come back from the server through Charles. It's just that the app doesn't seem to get the response and just sits there.</p> <p>So, here's the code. Thanks for any help!</p> <pre><code>public SyncVO sync(String userId, long lastUpdate, boolean includeFetch) throws IOException { SyncVO result = null; String url = BASE_URL + "users/" + userId + "/sync" + "?" + "fetch=" + includeFetch; if (lastUpdate &gt; 0) { url += "&amp;updatedSince=" + lastUpdate; } DefaultHttpClient httpclient = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(url); httpGet.setHeader("Accept", "application/json"); httpGet.setHeader("Accept-Encoding", "gzip"); httpGet.setHeader(AUTHORIZATION, BEARER + " " + mOAuthToken); httpclient.getParams().setParameter(CoreProtocolPNames.USER_AGENT, USER_AGENT_STRING); httpclient.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, false); HttpResponse response = httpclient.execute(httpGet); if (isUnauthorized(response)) { APPLICATION.needReauthentication(); return null; } if (response != null) { InputStream stream = response.getEntity().getContent(); Header contentEncoding = response.getFirstHeader("Content-Encoding"); if (contentEncoding != null &amp;&amp; contentEncoding.getValue().equalsIgnoreCase("gzip")) { stream = new GZIPInputStream(stream); } InputStreamReader inReader = new InputStreamReader(stream, "UTF-8"); JsonParser jp = mJsonFactory.createJsonParser(inReader); result = getObjectMapper().readValue(jp, SyncVO.class); } return result; } private ObjectMapper getObjectMapper() { return (new ObjectMapper() .configure(Feature.AUTO_DETECT_FIELDS, true) .configure(Feature.FAIL_ON_UNKNOWN_PROPERTIES, false) .configure(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true)); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload