1

Timeout error with Asychronous HTTP callout to wordpress site I am trying to make an asynchronous call to a wordpress site using HTTP callout method( using @Future). Everything works on sandbox and I was able to get 60% code coverage after hours of hit and trial methods. The issue started when it was deployed to production box, I am getting timeout error for every call to wordpress. I tried using request.timeout property with values ranging from 2 seconds to 120 seconds. Even then it gives me request time out error 408. My understanding with timeout is it will wait for specified time for a response before terminating with error. Also when it is an asychronous call, there should be no response. Please provide expert opinion on this topic. Below is my code

public class Wordpress_AsyncCall {

    @future (callout=true)
    public static void callwordpress(string endp){
        Httprequest req = new HttpRequest();
        req.setEndpoint(endp);
        req.setMethod('GET');
        req.setCompressed(true); // otherwise we hit a limit of 32000

        Http http = new Http();
        try{
        http.send(req);
        }
        catch(System.CalloutException e) {
           System.debug('Callout error: '+ e);
           }

   }
  • 1
    If you manually enter a Wordpress URL and then run the code you posted with exactly the same URL you get a timeout? Presumably you have setup the "Remote Site" (not that that being missing would normally cause a timeout)? – Keith C Nov 2 '15 at 18:08
  • The url works well in the browser. I have remote site settings for my destination. When running trial run, I found 1 out 5 message get posted while remaining returns a timeout error. – Vishal Dube Nov 3 '15 at 4:50
  • So 1 in 5 GET requests to the same URL work or with 5 different URLs only 1 works? – Keith C Nov 3 '15 at 8:34
  • It is the same URL and success is 1 in 5 – Vishal Dube Nov 3 '15 at 13:32
  • Perhaps the Wordpress site has throttling installed (e.g. wordpress.org/plugins/wordfence) that blocks your requests thinking they are malicious (which is you make them very frequently kinda are). – Keith C Nov 3 '15 at 14:55

Your Answer

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

Browse other questions tagged or ask your own question.