5

I am running a GET method of router on NodeJS with Express.js.

I am fetching data from MSSQL but my MSSQL server taking a time and my NodeJS server is not waiting for it more than approximately 15 seconds.

What should i do??

Tom
  • 1,387
  • 3
  • 19
  • 30
  • 15 seconds is very long for execute a query. Try to reduce that time by adding oen or more indexes. See also [this](http://stackoverflow.com/questions/23925284/how-to-modify-the-nodejs-request-default-timeout-time) SO question. – Jeroen Heier Oct 22 '16 at 10:46
  • Probably increase [`requestTimeout`](https://github.com/patriksimek/node-mssql#general-same-for-all-drivers). – robertklep Oct 22 '16 at 12:19
  • See if this helps: http://stackoverflow.com/questions/23925284/how-to-modify-the-nodejs-request-default-timeout-time – Tom Oct 23 '16 at 11:13

1 Answers1

7

You do everything right. But, default timeout in tedious is 15 seconds. Use requestTimeout for

let config = {
    user: global.config.database.username,
    password: process.env.database_pwd || process.env.DATABASE_PWD,
    server: global.config.database.host,
    port: 1433,
    database: global.config.database.database,
    requestTimeout: 180000
};

module.exports.connect = async () => {
    pool = await sql.connect(config);
}