function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vishal Dube 1Vishal Dube 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);
           }
        
   }
James LoghryJames Loghry
You should get a different error, but did you add the wordpress URL to the Remote Site Settings?  Setup->Security->Remote Site settings?
Vishal Dube 1Vishal Dube 1
Hi James,

I have remote site settings for my destination. The solution works at times but not always. I am not sure if something can be done in the code. Thanks for your response. I also tried setting timeout(2s to 60s)  for the HTTP request. Let me know if this can be accomplished by other ways
Vishal