1

I have a expressjs application hosted on Azure web app with Always On enabled.

I am using bookshelfjs to connect to the MySQL database which is hosted in another virtual server on Azure.

After sometime, when I call the web application I get below error, which told me it failed to connect to the database server:

select * from `member` where `name` = 'alvin' limit 1 -read ECONNRESET"

Is it related to the expressjs timeout problem?

Gary Liu
  • 13,758
  • 1
  • 17
  • 32
Alvin
  • 8,219
  • 25
  • 96
  • 177

1 Answers1

4

According to the similar issue on SO MySQL giving "read ECONNRESET" error after idle time on node.js server, it seems to be a MySQL connection issue.

As the answer said:

MySQL does indeed prune idle connections.

Please try to add the pool setting in the MySQL connection configuration in Knex. E.G,

var knex = require('knex')({
  client: 'mysql',
  connection: {
    host     : '127.0.0.1',
    user     : 'your_database_user',
    password : 'your_database_password',
    database : 'myapp_test'
  },
  pool: {
    min: 0,
    max: 7
  }
});

Please refer to http://knexjs.org/#Installation-pooling for more info.

Community
  • 1
  • 1
Gary Liu
  • 13,758
  • 1
  • 17
  • 32