Reputation: 71
I have created a Microsoft Teams notification bot with node and restify. This bot has been deployed as a Web App on Azure. The request to send a notification can take from 1 up to 4 minutes sometimes, and when it is more than 3 minutes I get as response a timeout (even tho after 1 minute I still receive the notification). We are working on optimizing that making it way faster, but meanwhile I need an hotfix and increase the request timeout. How can I do that with restify? Or how to do that in Azure as a Web App?
This is what I have tried so far:
const server = restify.createServer();
// Set request and connection timeouts
server.server.setTimeout(10 * 60 * 1000); // 10 minutes
server.server.timeout = 10 * 60 * 1000; // 10 minutes
server.server.keepAliveTimeout = 10 * 60 * 1000; // 10 minutes
but this didn't worked. From Azure I just set to keep the connection alive because I couldn't find any way to do that (and nothing changed at all).
Upvotes: 0
Views: 159
Reputation: 8694
I have taken reference from document to configure timeout in the app using NodeJs.
Code Snippet to set the timeout to 5 Minutes:
const server = restify.createServer();
server.timeout = 300000;
server.use(restify.plugins.bodyParser());
server.listen(process.env.port || process.env.PORT || 3978, () => {
console.log(`\nApp Started, ${server.name} listening to ${server.url}`);
});
Also add the application setting in the App Service=>Environment Variables
:
I have created Microsoft Teams notification bot with NodeJs and Restify using Visual Studio code.
[nodemon] starting `node --inspect=9239 ./src/index.js`
Debugger listening on ws://127.0.0.1:9239/51492aXXXXXe92c14e1
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
(node:8204) [DEP0111] DeprecationWarning: Access to process.binding('http_parser') is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
App Started, restify listening to http://[::]:3978
Invoke-Webrequest -Method POST -URI https://localhost:3978/api/notification
Navigate to Azure Bot=>Channels=>Microsoft Teams
, click on Open in Teams, redirects to the notification bot app uploaded into Teams client.
Invoke-Webrequest -Method POST -URI https://notification9c6356.azurewebsites.net/api/notification
Upvotes: 0