Synchronous Outbound Web Service Calls Timing Out After 2 min
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2023 08:52 PM - edited ‎09-28-2023 08:53 PM
Hi
I have a REST message using an HTTP POST request. It's an application used to retrieve data, and sometimes it takes more than 2 minutes to respond with the data. Even though the target instance has not responded, we receive either blank responses or socket errors in such cases. I've attempted to set the setHttpTimeout() both 3 minutes and 5 minutes, but it still fails. It appears that the API is only waiting for a response for 2 minutes.
var body = '{"product_num":"PROD20106","source": "PROD"}';
var r = new sn_ws.RESTMessageV2();
r.setEndpoint('endpoint');
r.setHttpMethod('POST');
r.setHttpTimeout('180000');
r.setRequestHeader("Authorization", 'Basic authentication');
r.setRequestHeader("x-api-key", "key here");
r.setRequestHeader("Content-Type", "application/json");
r.setRequestBody(body);
r.setHttpTimeout(180000);
var response = r.execute();
//response.waitForResponse(90);
var statusCode = response.getStatusCode();
if (statusCode === 200) {
var responseBody = JSON.parse(response.getBody());
gs.info("SRI Response statusCode: " + statusCode);
} else {
var err = 'Could not retrieve data - Request failed with code ' + statusCode;
gs.info("SRI Error: " + err);
}
I get outputs as
x_snc_price_master: START execution: 2023-09-28 01:59:33 {"product_num":"PROD20106","source": "PROD"} x_snc_price_master: Before REST request execution: 2023-09-28 01:59:33 {"product_num":"PROD20106","source": "PROD"} Socket error: Connection reset x_snc_price_master: Error: Could not retrieve data - Request failed with code 0 x_snc_price_master: After REST request execution: 2023-09-28 02:01:33 {"product_num":"PROD20106","source": "PROD"}
Tried with executeAsync() as well. Tried to modify the below properties as well.
'glide.http.outbound.max_timeout.enabled' to True
glide.http.outbound.max_timeout = 600000
glide.http.timeout' to '1750000'
'glide.http.connection_timeout' to '1000000'.
Also, I tried to configure the REST message and tested by hitting "TEST" which is OUT OF THE BOX rest message test feature. It is still failing at 2 mins. The API flaps exactly at 2 mins, and tried running the code in BS, in scoped/global its the same issue.
Any help on this in much appreciated.
Thanks
Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2023 11:19 PM
The time out may be happening at the End Point, I mean to say your target instance. Try asking the API provider to verify the configuration at their end.
And still if you want to check from your end only, Try setting the sys property glide.http.outbound.max_timeout to a maximum value.
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2023 12:59 AM
Hi @AnveshKumar M ,
No time out is happening at target instance we have checked it provides the response the data and it takes > 2 min (2.54 ) when checked in POSTMAN. We have also increased at target instance to 10mins. And we see 499 error at target instance as client is already closed.
Have already tried this option to increase 'glide.http.outbound.max', whatever value i provide and try, SNOW is flipping at exactly at 2 mins.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2023 01:24 AM
@srivatsa_tatti Have you checked the Transaction Quota Limits? Check in the following link and try increasing the suitable values and debug.
https://<INSTANCE_NAME>.service-now.com/sysrule_quota_list.do
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2023 01:39 AM - edited ‎09-29-2023 01:48 AM
Can i create a new rule to it? Could you please guide me how to use this?
I did try to add new record
Condition type = 'rest'
URL contains 'PackageLookup/' (part or target api)
And tried the API call, still same issue.