I have hosted my node js web app on HostEurope utilizing their virtual server and plesk.
My node app is basically used to generate subtitles of the provided videos utilizing OpenAI Whisper model deployed on another platform (baseten) and I am calling it via fetch request and getting the response in json format.
The API sometimes responds quickly and some time takes time depending upon the video sizes.
The issue is that my node app doesn’t wait for the api response if the third party API took some time to respond and it just dump 504 Gateway Timeout
can anybody know how to wait for an api which might took around (30 to 40) mint in nodejs?
Given below is the code snippet I used to call the third party api to get the subtitles
import fetch from 'node-fetch';
async function start() {
const resp = await fetch(
'https://model-lqz42jpw.api.baseten.co/development/predict',
{
method: 'POST',
headers: { Authorization: 'Api-Key YOUR_API_KEY' },
body: JSON.stringify(MODEL_INPUT),
}
);
const data = await resp.json();
console.log(data);
}
start();
I have already tried several methods to increase the timeout limit in plesk and node js which includes:
- Increasing the FastCGI limits server-wide
- Additional nginx directives field
- Also tried to increase the timeout limit in nodejs code as well like
server.listen(port); server.timeout = 1800000; ;
but none of the above techniques works.
can anybody know how to wait for an api which might took around (30 to 40) mint in nodejs?