How to increase the timeout for a REST response? (ECCResponseTimeoutException)

David Berdasco
Tera Contributor

Hi!

When launching a REST request, I’m getting ECCResponseTimeoutException (com.glide.ecc.ECCResponseTimeoutException: No response for ECC message request with sysid=957fa87adbb07300e9565d50cf961944 after waiting for 30 seconds in ECC Queue) nevertheless I set a bigger HTTP Timeout.

The endpoint I’m calling returns the response (but after 45 secs) via Postman, so it’s working, but slow…

Here is the code I’m using (testing through Scripts – Background):

var endpoint = "https://myEndpoint";
var authentication_profile = "1010102c5dbd03300e9561010cf961101d";
var MIDServer = "myMIDServer";

var REST_request = new sn_ws.RESTMessageV2();
REST_request.setHttpMethod("get");
REST_request.setHttpTimeout("5000");
REST_request.setEccParameter("skip_sensor", "true");
REST_request.setEndpoint(endpoint);
REST_request.setAuthenticationProfile("basic", authentication_profile);
REST_request.setMIDServer(MIDServer);

try {
    var response = REST_request.execute();
    gs.info(response.getStatusCode());
} catch(error) {
    gs.error(error);
}

Of course, I double-checked that the MID Server is up and running. Just changing the endpoint to a faster one works fine.

Thanks in advance!

1 ACCEPTED SOLUTION

Tom Boyle
Mega Expert

We reported this to Hi and received a response which worked for us:

"Please be informed that we have recently introduced a new property in order to control http connection timeouts for improved performance throughout the instance.

  • Property: glide.http.outbound.max_timeout
  • Description: Specifies the number of seconds that RESTMessageV2 and SOAPMessageV2 APIs wait for a response from a synchronous call. The maximum value is 30 seconds.


RESOLUTION: To define a timeout longer than 30 seconds, set the glide.http.outbound.max_timeout.enabledsystem property to false and use the waitForResponse() method to set the timeout (after setting that property to false you should be able to set different timeouts with waitForResponse()). For examples, see Asynchronous RESTMessageV2 example: https://docs.servicenow.com/bundle/madrid-application-development/page/app-store/dev_portal/API_refe...

and Asynchronous SOAPMessageV2 example:
https://docs.servicenow.com/bundle/madrid-application-development/page/app-store/dev_portal/API_refe...

If glide.http.outbound.max_timeout.enabled is set to true and a value is passed in the waitForResponse() method, the system uses the smallest value from either the waitForResponse() method or the glide.http.outbound.max_timeout system property."

View solution in original post

15 REPLIES 15

Rogers Cadenhe1
Giga Guru

I think there's a problem in this line:

REST_request.setHttpTimeout("5000");

The setHttpTimeout() method of sn_ws.RESTMessageV2() needs a number, not a string. It should be this for a 5,000 millisecond timeout:

REST_request.setHttpTimeout(5000);

Hi Rogers, thank you for the response

 

That's a good point, you're totally right. But, still doesn't work:

var endpoint = "myEndpoint";
var authentication_profile = "021jf284ujf48012345";
var MIDServer = "myMIDServer";

var REST_request = new sn_ws.RESTMessageV2();
REST_request.setHttpMethod("get");
REST_request.setHttpTimeout(5000);
REST_request.setEccParameter("skip_sensor", "true");
REST_request.setEndpoint(endpoint);
REST_request.setAuthenticationProfile("basic", authentication_profile);
REST_request.setMIDServer(MIDServer);

try {
    var response = REST_request.execute();
    gs.info(response.getStatusCode());
} catch(error) {
    gs.error(error);
}

 

com.glide.ecc.ECCResponseTimeoutException: No response for ECC message request with sysid=ab7d797adbb07300e9565d50cf961945 after waiting for 30 seconds in ECC Queue

Any other advise?

Thanks!

And this property "glide.rest.outbound.ecc_response.timeout"

Can you check if this helps

REST_request.setHttpTimeout(6000);

https://docs.servicenow.com/app_store/dev_portal/API_reference/RESTMessageV2/reference/r_RMV2-setHttpTimeout_N.html


Please mark my response as correct and helpful if it helped solved your question.
-Thanks

Hi Prateek, thanks for your response!

 

I tried your solution, but it neither worked: configured “glide.rest.outbound.ecc_response.timeout” through sys.properties (in the Global scope and in my application scope as well), and also through MID Server / server / myMIDServer / Properties.

 

Also tried changing the code to Async:

var endpoint = "https://myEndpoint";
var authentication_profile = "1010102c5dbd03300e9561010cf961101d";
var MIDServer = "myMIDServer";

var REST_request = new sn_ws.RESTMessageV2();
REST_request.setHttpMethod("get");
REST_request.setHttpTimeout(6000);
REST_request.setEccParameter("skip_sensor", "true");
REST_request.setEndpoint(endpoint);
REST_request.setAuthenticationProfile("basic", authentication_profile);
REST_request.setMIDServer(MIDServer);

try {
    var response = REST_request.executeAsync();
    response.waitForResponse(60);
    gs.info(response.getStatusCode());
} catch(error) {
    gs.error(error);
}

And of course, I have restarted the MID Server for each try, but it never worked, always the same response:

com.glide.ecc.ECCResponseTimeoutException: No response for ECC message request with sysid=ff0f4198db013300e9565d50cf96190c after waiting for 30 seconds in ECC Queue.

BTW, I’m in a Madrid PDI.

I suppose that it should be an easy way to increase that ECCResponseTimeout, but how? 

Thanks again!