504 Timeout errors with the Request API

We are getting the occasional 504 timeout error from the request API on a serverless App. We have also noted that the time the request API waits for a response from the Freshdesk API is timing out before it has responded which means the data is not loading in the App.

Is there anything we can do to make the Request API wait longer for a response?

Hey @RobAtOpinyin!
Are you using Request Method from SDK?
If so, there’s a option called maxAttempts: The maximum number of times a request will try to retrieve a response if a network or 429/5xx HTTP error occurs. The maximum permissible value for this argument is 5.
You can configure as well the retryDelay: The delay between retry requests, specified in milliseconds. The maximum permissible value for this argument is 1500 ms.
Keep in mind that the default serverless event timeout is 20s and if you are calling from frontend (SMI), you have a 5s timeout.

1 Like

Hi Samuel,

Yes. We are. Thanks for the tip. We will take a look at that.

hi @samuelpares . i am using the developing an front end app. while making an request to 3 party api using request templates it timesout after 5 secs without even waiting for the response.

is there any way to increase the timeout ?

Hi @Marri_Sri_Rahul_Sidd

It seems that now with request templates, the default timeout is 5secs and you can only change it by requesting in devassist:

https://dev-assist.freshworks.com/support/catalog/items/45

hi @samuelpares
the default timeout is 5 secs in frontend app or serverless apps?

wat is the max timeout for calling a 3rd party api from serverless app?

Hi @Marri_Sri_Rahul_Sidd

This applies in both frontend and serverless but you can use a different HTTP library in serverless that doesn’t have this restriction ie. Needle or Node-fetch. That said I think both these are libraries based on nodeJS fetch which I believe has a timeout of 30 secs by default. I believe you can change that but I don’t know how.

@Marri_Sri_Rahul_Sidd You are probably looking at this solution already but just in case you can use the SMI functionality to call a method in a serverless app that uses a third party app. This would solve your front end timeout issue.

hi @RobAtOpinyin
yeah i am using SMI functionality but i have some api’s which responds after 10-15 seconds, so just to be on safer side i want to call those from server.js.
do you have references or docs which supports calling of apis from the server.js using node-fetch or needle ?
do we need to add in dependencies node-fetch or needle in manifest.json ? if we use either of them for callouts in server.js

@Marri_Sri_Rahul_Sidd - look them up on npm for full details of how to use. With node-fetch you need to use v2 rather than v3 as v3 does not support commonJS and you can only use commonJS modules in serverless apps.