Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

REST API Timeout

Avatar

Avatar
Validate 1
Level 2
ishanishah
Level 2

Likes

5 likes

Total Posts

19 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 2
ishanishah
Level 2

Likes

5 likes

Total Posts

19 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Affirm 1
View profile
ishanishah
Level 2

09-05-2019

Hi Team,

We are calling an API endpoint from Adobe Campaign Java script activity by using :

var http = new HttpClientRequest(<Our API URL>) and the request is timing out before it could get a response from the End point/API (timing out at approximately 5 mins),

Is there any attribute in server config file which would set the timeout value to a higher number > 5 mins? OR

Do we have to add timeout attribute in the code itself. Do you have a sample code to share?

Thanks,

Ishani

Replies

Avatar

Avatar
Give Back 25
MVP
Venu_Reddy
MVP

Likes

163 likes

Total Posts

171 posts

Correct Reply

53 solutions
Top badges earned
Give Back 25
Give Back 10
Give Back 5
Give Back 3
Give Back
View profile

Avatar
Give Back 25
MVP
Venu_Reddy
MVP

Likes

163 likes

Total Posts

171 posts

Correct Reply

53 solutions
Top badges earned
Give Back 25
Give Back 10
Give Back 5
Give Back 3
Give Back
View profile
Venu_Reddy
MVP

09-05-2019

Hello Ishani,

Try the following

  1. var http = new HttpClientRequest("yourhost.com"
  2. http.execute() 
  3. var response = http.response 
  4. for(var i in response.header) 
  5.   logInfo("header[" + i + "] => " + response.header[i]) 

Should give you something like

js3 header[Date] => Wed, 05 Jul 2017 10:10:13 GMT

js3 header[Server] => Apache/2.2.22 (Debian)

js3 header[Vary] => Accept-Encoding

js3 header[Content-Length] => 291

js3 header[Keep-Alive] => timeout=5, max=100

js3 header[Connection] => Keep-Alive

js3 header[Content-Type] => text/html; charset=iso-8859-1  

You can use the following code as well

var API = 'http://yourwebserviceendpoint.com'

var http = new  HttpClientRequest(API);

http.method = "GET";

http.header["Content-Type"] = "application/json";

http.header["Accept"] = "application/json";

http.header["Authorization"] = "Basic Z3XNlbmRleHRlc3QxQGdtYWlsLmNvbTpsb2dpbjEyMzQ="; // replace with your authorization code

http.execute();

var response = http.response;

Regards,

Venu

Avatar

Avatar
Validate 1
Level 2
ishanishah
Level 2

Likes

5 likes

Total Posts

19 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 2
ishanishah
Level 2

Likes

5 likes

Total Posts

19 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Affirm 1
View profile
ishanishah
Level 2

10-05-2019

Thanks Venu.

We are able to send the request but it seems to time out after 5 minutes. My questions is - How do we increase the time out to 10 mins instead?

Avatar

Avatar
Give Back 25
MVP
Venu_Reddy
MVP

Likes

163 likes

Total Posts

171 posts

Correct Reply

53 solutions
Top badges earned
Give Back 25
Give Back 10
Give Back 5
Give Back 3
Give Back
View profile

Avatar
Give Back 25
MVP
Venu_Reddy
MVP

Likes

163 likes

Total Posts

171 posts

Correct Reply

53 solutions
Top badges earned
Give Back 25
Give Back 10
Give Back 5
Give Back 3
Give Back
View profile
Venu_Reddy
MVP

10-05-2019

Hello Ishani,

The default connect timeout for outgoing http connection is 5sec.

You can change the connection timeout in server.conf file using the attribute value http_connect_timeout.

Click here for more details http://docs.graylog.org/en/3.0/pages/configuration/server.conf.html#web-rest-api

Regards,

Venu

Avatar

Avatar
Validate 1
MVP
Jean-Serge_Biro
MVP

Likes

353 likes

Total Posts

464 posts

Correct Reply

153 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 250
View profile

Avatar
Validate 1
MVP
Jean-Serge_Biro
MVP

Likes

353 likes

Total Posts

464 posts

Correct Reply

153 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 250
View profile
Jean-Serge_Biro
MVP

10-05-2019

Hi Isha,

Please change your serverConf.xml file, the section with urlPermission to allow outgoing connection.

This is documented in section "Outgoing connection protection" in this documentation:

Configuring Campaign server

It was added about 2 years ago in a build for security reasons.

Regards
J-Serge

Avatar

Avatar
Validate 1
MVP
Jean-Serge_Biro
MVP

Likes

353 likes

Total Posts

464 posts

Correct Reply

153 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 250
View profile

Avatar
Validate 1
MVP
Jean-Serge_Biro
MVP

Likes

353 likes

Total Posts

464 posts

Correct Reply

153 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 250
View profile
Jean-Serge_Biro
MVP

10-05-2019

Hi Isha,

Moreover, you should always use:
try{

     <your code>

}

catch(e){

     logWarning("Error number: " + e );
}

so the timeout message would have been much more clearer.
Same for other kind of errors.

Then you have a look in the web.log file (on mta server or on applicative server depending on the pbject type) to read the error details.

Regards
J-Serge