HttpResponse returns a 502 Error, doesn't appear to hit endpoint
<p>I'm working on an application that uses HttpResponse for network calls. </p>

<p>Occasionally (about 30% of the time) network calls seem to fail with a 502 returning from the server. When checking the server logs, It appears that the server never received the request. </p>

<p>The logic doesn't seem bad, however, and it does work most of the time. I am communicating to the server via JSON.</p>

<pre><code>HttpClient client = new DefaultHttpClient();
HttpPost method = new HttpPost( BASE_URL + endpoint )
...add json entity
method.addHeader( "content-type", "application/json" );
        method.addHeader( "accept", "application/json" );
</code></pre>

<p>....call below function w client/method</p>

<pre><code>protected HttpResponse invoke( HttpClient client, HttpUriRequest method ) throws ServiceException {

    HttpResponse response = null;

    try {
        response = client.execute( method );
    } catch ( //catch statements here ....)

    int status = response.getStatusLine().getStatusCode();
    //status = 502
}
</code></pre>

<p>The interesting thing about this call failing is that it's the exact same call across devices, and the server it's hitting is 20 feet away, although it does happen on a different server located in another state.</p>

<p>I can't see why it works sometimes but not others.</p>
