1

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.

1
5

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

2
  • Please note I am asking why is this occurring on the Force.com Platform and not why does this occur in Java. Does your answer apply to the Force.com Platform as well?
    – sfelf
    Dec 13 '12 at 18:24
  • The Force.com platform is built on java and often this kind of behaviour manifests itself because of the underlying java behaviour. Dec 13 '12 at 18:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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