Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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=, 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 Platform and not why does this occur in Java.

share|improve this question
Looking at this forum :… Looks like in general the transaction was aborted, something went wrong with connection or response handling/ there was issue with keeping the connection live.Now how to avoid this :(, I do not know much about this but the -1 in the statuscode indicates something went wrong. I tried looking up noluck though… – Rao Dec 13 '12 at 0:08
up vote 4 down vote accepted

-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 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.

share|improve this answer
Please note I am asking why is this occurring on the Platform and not why does this occur in Java. Does your answer apply to the Platform as well? – sfelf Dec 13 '12 at 18:24
The platform is built on java and often this kind of behaviour manifests itself because of the underlying java behaviour. – Bob Buzzard Dec 13 '12 at 18:38
Thanks so much for the clarification! – sfelf Dec 13 '12 at 18:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.