You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am getting this error when there is less traffic or there is gap between requests.
error: { TimeoutError: ResourceRequest timed out
at ResourceRequest._fireTimeout (/home/munir/node-workspace/server/node_modules/generic-pool/lib/ResourceRequest.js:62:17)
at Timeout.bound (/home/munir/node-workspace/server/node_modules/generic-pool/lib/ResourceRequest.js:8:15)
at ontimeout (timers.js:365:14)
at tryOnTimeout (timers.js:237:5)
at Timer.listOnTimeout (timers.js:207:5) name: 'TimeoutError' }
If you're using transactions in your calls it seems to be an issue. Improper usage of them makes pool get stacked. Try to get rid off them.
Reacted by Anton Ivanov, Dee Clawson, Will Morgan, Victor Zhinzherov, Mario Camou, Oliver Wangler, Kuniaki Tran, Denis, Stephan Ahlf, rushabhOrdex and 2 more
I got a similar problem with ESOCKETTIMEOUT. It happened when I deploy my app and my docker install the latest version of tedious (v2.3.1, I think) as its dependency. When I ran my batch jobs which used quite a large and complex query, it made a lot of timeout which didn't happen before in the previous version. While I don't know how write reproduce steps without using the same database and query, My current solution is to force its dependency to install tedious (v2.1.1) using npm-shrinkwrap.json that I made from my local repo.
@catcher-in-the-try They did same thing which is already done by some developers in pending PR(coopernurse/node-pool#198 & coopernurse/node-pool#221) of generic-pool. So, looks like there is issue in generic-pool
I had a really hard time on my customer with this too. Managed to reduce the damage somehow with the config below, but its urgent to fix this one. pool: { max: 100000, min: 1, idleTimeoutMillis: 50, evictionRunIntervalMillis: 5, softIdleTimeoutMillis: 5 }
@labs20 Are you not facing more issue with this configuration? I think 50ms timeout will create this issue more frequently. Also, It will increase chances of this error.
Thanks, though I wasn't looking for an explanation on why poolCreate is called when it's called, i wanted to understand what is it that you fixed by adding that reject in there.
@dsbert That's interesting. I haven't seen an ETIMEOUT error crash our Node services yet but I'll keep an eye out for that. Do you have a stack trace you can share? If there's a defect in my PR then would be keen to fix...
I am also facing same error frequently. So I have updated node-mssql version to v4.2.2. I'll keep an eye out for that.
@dsbert That's interesting. I haven't seen an ETIMEOUT error crash our Node services yet but I'll keep an eye out for that. Do you have a stack trace you can share? If there's a defect in my PR then would be keen to fix...
I am also facing same error frequently. So I have updated node-mssql version to v4.2.2. I'll keep an eye out for that.
I updated node-mssql version to v4.2.2. But I am facing same error too. Connection timeout.
@LoveMeWithoutAll Can you provide some code that reproduces the error, the config and also details of the environment / platform you are running on, please?
@LoveMeWithoutAll Can you provide some code that reproduces the error, the config and also details of the environment / platform you are running on, please?
@dhensby I have encountered connection timeout error even if upgraded node-mssql to v4.2.2. I couldn't reproduce the error immediately. But after running 1~2 days, the error has occured. Getting connection every 1 second may raise the error? I'm speculating so. At now, I changed timing of getting connection to only once at a process lifetime, and keeping an eye out for that.
environment/platform
Windows Server 2008R2 standard
MSSQL: Microsoft SQL Server 2014 - 12.0.4100.1 (X64)
Apr 20 2015 17:29:27
Copyright (c) Microsoft Corporation
Enterprise Edition (64-bit) on Windows NT 6.3 (Build 9600: ) (Hypervisor)
{ message: 'Error on getConnectionPool error in catch in db.js',
level: 'error',
timestamp: '2018-10-23 10:27:42',
[Symbol(level)]: 'error',
[Symbol(message)]: '{"message":"Error on getConnectionPool error in catch in db.js","level":"error","timestamp":"2018-10-23 10:27:42"}' }
{ ConnectionError: Failed to connect to 165.246.17.29:3361 in 15000ms
at Connection.tedious.once.err (D:\push_engine\FcmPushEngine\node_modules\mssql\lib\tedious.js:237:17)
at Object.onceWrapper (events.js:315:30)
at emitOne (events.js:116:13)
at Connection.emit (events.js:211:7)
at Connection.connectTimeout (D:\push_engine\FcmPushEngine\node_modules\tedious\lib\connection.js:944:12)
at Timeout._onTimeout (D:\push_engine\FcmPushEngine\node_modules\tedious\lib\connection.js:913:16)
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5)
at Timer.listOnTimeout (timers.js:290:5)
code: 'ETIMEOUT',
originalError:
{ ConnectionError: Failed to connect to 165.246.17.29:3361 in 15000ms
at ConnectionError (D:\push_engine\FcmPushEngine\node_modules\tedious\lib\errors.js:12:12)
at Connection.connectTimeout (D:\push_engine\FcmPushEngine\node_modules\tedious\lib\connection.js:944:28)
at Timeout._onTimeout (D:\push_engine\FcmPushEngine\node_modules\tedious\lib\connection.js:913:16)
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5)
at Timer.listOnTimeout (timers.js:290:5)
message: 'Failed to connect to 165.246.17.29:3361 in 15000ms',
code: 'ETIMEOUT' },
name: 'ConnectionError',
level: 'error',
timestamp: '2018-10-23 10:27:42',
[Symbol(level)]: 'error',
[Symbol(message)]: '{"code":"ETIMEOUT","originalError":{"message":"Failed to connect to 165.246.17.29:3361 in 15000ms","code":"ETIMEOUT"},"name":"ConnectionError","level":"error","timestamp":"2018-10-23 10:27:42"}' }
@LoveMeWithoutAll Something about your getConnectionPoolcode feels weird because you're always reassigning connectionPool with a new pool rather than making use of a pool that may have already been created...
Can you try changing getConnectionPool to be something more like:
There's a possibility you're just creating a connection pool every time and eventually hitting the maximum number of connections allowed on the server and so the new pool never connects again.
Can you monitor the number of active connections on the server and see if it is constantly increasing or remains stable?
I used below query to check the number of active connections
SELECT PROGRAM_NAME, HOSTNAME, STATUS, COUNT(DBID) AS NumberOfConnections
FROMsys.sysprocessesWHERE PROGRAM_NAME ='node-mssql'GROUP BY PROGRAM_NAME, HOSTNAME, STATUS
It shouldn't matter if the connectionPool is connected or not because it could be in the process of connecting when it's called and you'll still be creating many pools that you lose reference to and thus can't close...
perhaps you should just un-assign the variable in the catch block?
It shouldn't matter if the connectionPool is connected or not because it could be in the process of connecting when it's called and you'll still be creating many pools that you lose reference to and thus can't close...
perhaps you should just un-assign the variable in the catch block?
@dhensby Thank you for your advice! I have agreed with you. I changed my code.
@dhensby Finally I got a same error Failed to connect to 165.246.17.29:3361 in 15000ms after 6 days running. No too many connections were in there. So I edited my code. When error occured, the app would be restarted by process.exit() without any trying to reconnect on DB.
Activity
labs20 commentedon Feb 27, 2018
+1, and its random.
Please any help?
glebson1 commentedon Mar 5, 2018
If you're using transactions in your calls it seems to be an issue. Improper usage of them makes pool get stacked. Try to get rid off them.
munir131 commentedon Mar 5, 2018
@glebson1 Thanks for your reply. But, I am not getting how it is affecting to it?
munir131 commentedon Mar 7, 2018
@patriksimek Can you give me any hint that can help?
tkunanuntakij commentedon Mar 7, 2018
I got a similar problem with ESOCKETTIMEOUT. It happened when I deploy my app and my docker install the latest version of
tedious(v2.3.1, I think) as its dependency. When I ran my batch jobs which used quite a large and complex query, it made a lot of timeout which didn't happen before in the previous version. While I don't know how write reproduce steps without using the same database and query, My current solution is to force its dependency to install tedious (v2.1.1) usingnpm-shrinkwrap.jsonthat I made from my local repo.munir131 commentedon Mar 8, 2018
@gentlerainsky Thanks. I will try it.
munir131 commentedon Mar 14, 2018
@gentlerainsky I tried by using tedious (v1.x) But still getting resourceRequest timeout issue.
anton-bot commentedon Mar 16, 2018
Sequelize fixed this bug. Please just reference their pull request. This is a huge issue that prevents normal operation!
sequelize/sequelize#8815
munir131 commentedon Mar 16, 2018
@catcher-in-the-try They did same thing which is already done by some developers in pending PR(coopernurse/node-pool#198 & coopernurse/node-pool#221) of
generic-pool. So, looks like there is issue in generic-poolJankiGadhiya commentedon Mar 16, 2018
Guys, Any updates in this? My production is heading to a big event today and I am in a big mess because of this issue.
labs20 commentedon Mar 16, 2018
I had a really hard time on my customer with this too. Managed to reduce the damage somehow with the config below, but its urgent to fix this one.
pool: { max: 100000, min: 1, idleTimeoutMillis: 50, evictionRunIntervalMillis: 5, softIdleTimeoutMillis: 5 }munir131 commentedon Mar 16, 2018
@labs20 Are you not facing more issue with this configuration? I think 50ms timeout will create this issue more frequently. Also, It will increase chances of this error.
labs20 commentedon Mar 16, 2018
Well, at least on my customer server it seems to have reduced the problem.
munir131 commentedon Mar 20, 2018
@catcher-in-the-try @labs20 It is working fine for me after I used https://github.com/munir131/node-mssql
anton-bot commentedon Mar 20, 2018
@munir131 I couldn't figure out how to use, it doesn't seem to be documented or published to NPM.
51 remaining items
willmorgan commentedon Sep 9, 2018
Cool, good luck.
LoveMeWithoutAll commentedon Oct 22, 2018
I am also facing same error frequently. So I have updated node-mssql version to v4.2.2. I'll keep an eye out for that.
madal3x commentedon Oct 22, 2018
There is a fix in tedious that would be nice to be taken into node-mssql to fix this issue: tediousjs/tedious#769
madal3x commentedon Oct 22, 2018
Ah sorry, i see it was included in 4.2.2
LoveMeWithoutAll commentedon Oct 23, 2018
I updated node-mssql version to v4.2.2. But I am facing same error too. Connection timeout.
dhensby commentedon Oct 23, 2018
@LoveMeWithoutAll Can you provide some code that reproduces the error, the config and also details of the environment / platform you are running on, please?
LoveMeWithoutAll commentedon Oct 25, 2018
@dhensby I have encountered connection timeout error even if upgraded node-mssql to v4.2.2. I couldn't reproduce the error immediately. But after running 1~2 days, the error has occured. Getting connection every 1 second may raise the error? I'm speculating so. At now, I changed timing of getting connection to only once at a process lifetime, and keeping an eye out for that.
Apr 20 2015 17:29:27
Copyright (c) Microsoft Corporation
Enterprise Edition (64-bit) on Windows NT 6.3 (Build 9600: ) (Hypervisor)
Error rasing code is below.
error log is below
dhensby commentedon Oct 25, 2018
@LoveMeWithoutAll Something about your
getConnectionPoolcode feels weird because you're always reassigningconnectionPoolwith a new pool rather than making use of a pool that may have already been created...Can you try changing
getConnectionPoolto be something more like:const getConnectionPool = async () => { + if (connectionPool) { + return connectionPool; + } try { connectionPool = await new sql.ConnectionPool(dbConfig).connect() connectionPool.on("error", async err => { await closeConnectionPool() onDbError(err, "getConnectionPool error") }) } catch (err) { onDbError(err, "getConnectionPool error in catch") } }There's a possibility you're just creating a connection pool every time and eventually hitting the maximum number of connections allowed on the server and so the new pool never connects again.
Can you monitor the number of active connections on the server and see if it is constantly increasing or remains stable?
LoveMeWithoutAll commentedon Oct 26, 2018
@dhensby Thank you for your guide! I changed code as you recommended. And now 3 different version apps is running on my each server.
connectionPool)Until now, the number of active connections on the all servers are stable.
I'm keeping an eye out for that.
P.S.
const getConnectionPool = async () => { try { + if (connectionPool && connectionPool.connected) return connectionPool = await new sql.ConnectionPool(dbConfig).connect() connectionPool.on("error", async err => { await closeConnectionPool() onDbError(err, "getConnectionPool error") }) } catch (err) { onDbError(err, "getConnectionPool error in catch") } }dhensby commentedon Oct 26, 2018
It shouldn't matter if the connectionPool is connected or not because it could be in the process of connecting when it's called and you'll still be creating many pools that you lose reference to and thus can't close...
perhaps you should just un-assign the variable in the catch block?
LoveMeWithoutAll commentedon Oct 30, 2018
@dhensby Thank you for your advice! I have agreed with you. I changed my code.
const getConnectionPool = async () => { try { + if (connectionPool) return connectionPool = await new sql.ConnectionPool(dbConfig).connect() connectionPool.on("error", async err => { await closeConnectionPool() onDbError(err, "getConnectionPool error") }) } catch (err) { + connectionPool = null onDbError(err, "getConnectionPool error in catch") } } const closeConnectionPool = async () => { try { await connectionPool.close() } catch (err) { + connectionPool = null onDbError(err, "closeConnectionPool error") } }And so far, there is no connection problem in my app I am keeping an eye for 4 days!
dhensby commentedon Oct 31, 2018
Fantastic
LoveMeWithoutAll commentedon Nov 14, 2018
@dhensby Finally I got a same error
Failed to connect to 165.246.17.29:3361 in 15000msafter 6 days running. No too many connections were in there. So I edited my code. When error occured, the app would be restarted byprocess.exit()without any trying to reconnect on DB.dhensby commentedon Nov 22, 2018
@LoveMeWithoutAll ok, so is it now completely resolved for you by fixing your code?
LoveMeWithoutAll commentedon Nov 23, 2018
@dhensby All problems is resolved by restarting app when error occured. Thank you for your kindness!!