How to avoid the timeout error in Rest API request

ramesh_r
Giga Sage

Hi All,

When i am running the Rest API its getting below error, but its working fine in the Postman.

Please help me how to avoid this error

Error: -

org.apache.commons.httpclient.ConnectTimeoutException: The host did not accept the connection within timeout of 10000 ms when posting to http://199.16.197.107:808/service/features

 

find_real_file.png

 

Thanks

Ramesh R

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron

Hi Ramesh,

you can try increasing the timeout for Outbound REST.

  • 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.

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

https://hi.service-now.com/kb_view.do?sysparm_article=KB0694711

Another method is while you are consuming the Rest message using script you can use this method

setHttpTimeout(Number timeoutMs)

https://developer.servicenow.com/dev.do#!/reference/api/orlando/server/sn_ws-namespace/c_RESTMessage...

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron

Hi Ramesh,

you can try increasing the timeout for Outbound REST.

  • 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.

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

https://hi.service-now.com/kb_view.do?sysparm_article=KB0694711

Another method is while you are consuming the Rest message using script you can use this method

setHttpTimeout(Number timeoutMs)

https://developer.servicenow.com/dev.do#!/reference/api/orlando/server/sn_ws-namespace/c_RESTMessage...

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

I have used MID server then  i created this property 

  • 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.

Now its working as expected

So documentation says if its set to a higher value it will default to 30 secs, so in order to achieve this first step would be to set the property to false glide.http.outbound.max_timeout and add glide.rest.outbound.ecc_response.timeout to a higher value than 300 secs which is default

Also how to set sm.setHttpTimeout(6000) if REST API call is being made via flow action

VaranAwesomenow_0-1667681184645.png

VaranAwesomenow_1-1667682006585.png

 

VaranAwesomenow_2-1667682146581.png

 

This property is used for asynchronous (or executeAsync()) calls. What property is used for synchronous (execute()) calls?