• Brett Phillips 9
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
I have a puzzling issue that I cannot figure out. I have a very simple REST service running on an external server returning a small JSON response for every GET request. It is set up as a simple service to verify I can connect to it from Salesforce. This service returns without issue when hit from a browser, CURL, etc. However, when we try from Salesforce, it takes a number of tries to get a return. Here is the simple Apex code I've wrote the check the service:
 
Http h = new Http();
HttpRequest req = new HttpRequest();
String url = '<webservice being called>';
req.setEndpoint(url);
req.setMethod('GET');
HttpResponse res;
while(res == null){   
	try{
		res = h.send(req);
		System.debug(res.getBody());  
	} catch(CalloutException e) {
		System.debug(e.getMessage());
	}
}

When running this section of code, there are a number of times "Read timed out" happens when making the HttpResponse call before a successful response is received. Here are a couple examples of an output from the logs:

User-added image

Success request after 1 attempt

As you can see, there is no reason or frequency for the timeouts. I have control over the server that is accepting the requests but unfortuantely I do not have control over the network level firewall. I have been told there are no restrictions to the network for any and all traffic. That seems to be the case because calls can be made from everywhere with issues. On the server logs, I see a successful request coming in but do not see any requests when there is a timeout.

Is there anything from the Salesforce side that could be causing this issue? I want to make sure I cover all possible points in this process that could be causing this failure. 
I have a puzzling issue that I cannot figure out. I have a very simple REST service running on an external server returning a small JSON response for every GET request. It is set up as a simple service to verify I can connect to it from Salesforce. This service returns without issue when hit from a browser, CURL, etc. However, when we try from Salesforce, it takes a number of tries to get a return. Here is the simple Apex code I've wrote the check the service:
 
Http h = new Http();
HttpRequest req = new HttpRequest();
String url = '<webservice being called>';
req.setEndpoint(url);
req.setMethod('GET');
HttpResponse res;
while(res == null){   
	try{
		res = h.send(req);
		System.debug(res.getBody());  
	} catch(CalloutException e) {
		System.debug(e.getMessage());
	}
}

When running this section of code, there are a number of times "Read timed out" happens when making the HttpResponse call before a successful response is received. Here are a couple examples of an output from the logs:

User-added image

Success request after 1 attempt

As you can see, there is no reason or frequency for the timeouts. I have control over the server that is accepting the requests but unfortuantely I do not have control over the network level firewall. I have been told there are no restrictions to the network for any and all traffic. That seems to be the case because calls can be made from everywhere with issues. On the server logs, I see a successful request coming in but do not see any requests when there is a timeout.

Is there anything from the Salesforce side that could be causing this issue? I want to make sure I cover all possible points in this process that could be causing this failure.