Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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.

share|improve this question
    
Looking at this forum : stackoverflow.com/questions/7994073/android-https-status-code-1 stackoverflow.com/questions/11415967/… 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 salesforce.com/us/developer/docs/apexcode/Content/… –  rao Dec 13 '12 at 0:08
add comment

1 Answer 1

up vote 3 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 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.

share|improve this answer
    
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. –  Bob Buzzard Dec 13 '12 at 18:38
    
Thanks so much for the clarification! –  sfelf Dec 13 '12 at 18:52
add comment

Your Answer

 
discard

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.