Find your content:

Search form

You are here

What does an HTTP Response with a Status Code of -1 indicate?

 
Share

I am making a web callout in a Batch Apex class and occasionally I am receiving an HTTPResponse with a StatusCode = -1 and a Status = null. Any ideas on what this indicates?

Below are the entries from the debug log:

15:31:12.416 (5416593000)|CALLOUT_REQUEST|[10]|System.HttpRequest[Endpoint=https://sample.com/changed, Method=PUT]
15:31:12.574 (5574563000)|CALLOUT_RESPONSE|[10]|System.HttpResponse[Status=null, StatusCode=-1]

Edit: Please note I am asking about why this is occurring on the Force.com Platform and not why does this occur in Java.


Attribution to: sfelf

Possible Suggestion/Solution #1

-1 isn't a valid HTTP response code according to the specification, so it seems unlikely the server is providing this response to your request.

There have been a few threads on various java support sites (and the Force.com platform is built on java) over the years, but no conclusive answers. Prevailing theory is that the status is set to null and the statuscode set to -1 when the response object is constructed, and then something happens to the connection that means the request doesn't complete, so these defaults are never overwritten with real values.

What hasn't been answered satisfactorily in any of these threads is how the connection can go bad without an exception being thrown.

If there's nothing in the endpoint server logs to indicate a problem, it sounds like you need to retry the request if you see this status.


Attribution to: Bob Buzzard
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/5375

My Block Status

My Block Content