You need to sign in to do that
Don't have an account?
mysteriousaura
Apex Callout timed out during POST to amazon aws in the sandbox testing env
Hello,
I have a apex callout to POST a list of contact records to a amazon aws server. We are testing it in the test environment but I get a Callout error: System.CalloutException: Read timed out - error. Can someone help me?
Here is the code:
HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
Http http = new Http();
req.setEndpoint('callout:EndPoint/process');
req.setMethod('POST');
req.setHeader('Content-Type', 'application/json');
req.setBody(gen.getAsString());
//req.setBody(test);
req.setCompressed(false); // otherwise we hit a limit of 32000
System.debug('Post Complete');
try {
if(!Test.isRunningTest())
{
res = http.send(req);
}
}
catch(System.CalloutException e) {
System.debug('Callout error: '+ e);
System.debug(res.toString());
}
System.debug('Post response' + res.getBody());
End point is a named credential - http://xxx-xxxx-zcx-1454.us-east-1.elb.amazonaws.com:2322
Would really appreciate some help. It is my first time writing a callout!
I have a apex callout to POST a list of contact records to a amazon aws server. We are testing it in the test environment but I get a Callout error: System.CalloutException: Read timed out - error. Can someone help me?
Here is the code:
HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
Http http = new Http();
req.setEndpoint('callout:EndPoint/process');
req.setMethod('POST');
req.setHeader('Content-Type', 'application/json');
req.setBody(gen.getAsString());
//req.setBody(test);
req.setCompressed(false); // otherwise we hit a limit of 32000
System.debug('Post Complete');
try {
if(!Test.isRunningTest())
{
res = http.send(req);
}
}
catch(System.CalloutException e) {
System.debug('Callout error: '+ e);
System.debug(res.toString());
}
System.debug('Post response' + res.getBody());
End point is a named credential - http://xxx-xxxx-zcx-1454.us-east-1.elb.amazonaws.com:2322
Would really appreciate some help. It is my first time writing a callout!
If you're sending a lot of data - you may want to break this thing up into smaller chunks via BATCH Apex. Your comment of "otherwise we hit a limit of 32000" makes me think that it's just taking too darned long to send the data. Your AWS sandbox also probably is a lower-powered instance so it would take longer to process that data anyways.
Otherwise, you can increase the callout timeout, but I'd do the BATCH route to be more "best practice" about it. =)
Check this out: http://salesforce.stackexchange.com/questions/46364/how-to-set-timeout-for-web-service-call
I am not sending a lot of data. It is triggered when a new record is created in the contact object manually.
I tried
req.setTimeout(20000);
but I am getting the same error. Any other ideas or should I increase Timeout?
Thanks
Jyoti
I used a REST client and it works fine. I was working with a load balance URL and was getting the above error.
I tried to use the URL of the actual box and now I am getting:
System.HttpResponse[Status=Forbidden, StatusCode=403]
The following error was encountered while trying to retrieve the URL: <a href="http://10.101.7.105:8384/process">http://10.101.7.105:8384/process</a></p>
<p><b>Access Denied.</b></p>
Access control configuration prevents your request from being allowed at this time. Please contact your service provider if you feel this is incorrect.</p>
Generated Mon, 24 Aug 2015 14:25:44 GMT by proxy-chi.net.salesforce.com (squid)</p>
Any idea?
This one fails with Callout error: System.CalloutException: Read timed out - System.HttpResponse[Status=null, StatusCode=0]
I really appreciate your help on this!
Can you see any logs on the Amazon side that may give a hint to what's happening when Salesforce attempts to connect? Are you administering the AWS instance or do you have a team doing that for you?
I got it working. Apparently some security configurations on the AWS end. I dont have the details of what exactly needed to be configured.
Thanks for your help :)
Anytime!