[NODE v18] Failed to connect to {server} - socket hang up (code: ESOCKET)
See original GitHub issueEverything works in Node v14 and v16 (haven’t used v17 as it isn’t LTS or a candidate for it). This issue seems to only pop up with the latest current v18.
Note: sensitive data has been omitted.
Actual behaviour:
Error:: ConnectionError [SequelizeConnectionError]: Failed to connect to {sql_server_address}:1433 - socket hang up
at ConnectionManager.connect ([omitted]]backend/src/node_modules/sequelize/src/dialects/mssql/connection-manager.js:138:17)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at ConnectionManager._connect ([omitted]]backend/src/node_modules/sequelize/src/dialects/abstract/connection-manager.js:326:24)
at [omitted]]backend/src/node_modules/sequelize/src/dialects/abstract/connection-manager.js:250:32
at ConnectionManager.getConnection ([omitted]]backend/src/node_modules/sequelize/src/dialects/abstract/connection-manager.js:280:7)
at [omitted]]backend/src/node_modules/sequelize/src/sequelize.js:629:26
at NameService.getMessage ([omitted]]backend/src/src/app/app.service.ts:105:34)
at bootstrapFactory ([omitted]]backend/src/src/common/common.utils.ts:42:5) {
parent: ConnectionError: Failed to connect to {sql_server_address}:1433 - socket hang up
at Connection.socketError ([omitted]]backend/src/node_modules/tedious/src/connection.ts:2222:28)
at Connection.socketEnd ([omitted]]backend/src/node_modules/tedious/src/connection.ts:2239:12)
at Socket.<anonymous> ([omitted]]backend/src/node_modules/tedious/src/connection.ts:2013:37)
at Socket.emit (node:events:549:35)
at endReadableNT (node:internal/streams/readable:1359:12)
at processTicksAndRejections (node:internal/process/task_queues:82:21) {
code: 'ESOCKET',
isTransient: undefined
},
original: ConnectionError: Failed to connect to {sql_server_address}:1433 - socket hang up
at Connection.socketError ([omitted]]backend/src/node_modules/tedious/src/connection.ts:2222:28)
at Connection.socketEnd ([omitted]]backend/src/node_modules/tedious/src/connection.ts:2239:12)
at Socket.<anonymous> ([omitted]]backend/src/node_modules/tedious/src/connection.ts:2013:37)
at Socket.emit (node:events:549:35)
at endReadableNT (node:internal/streams/readable:1359:12)
at processTicksAndRejections (node:internal/process/task_queues:82:21) {
code: 'ESOCKET',
isTransient: undefined
}
}
Error:: ConnectionError [SequelizeConnectionError]: Failed to connect to {sql_server_address}:1433 - socket hang up
at ConnectionManager.connect ([omitted]]backend/src/node_modules/sequelize/src/dialects/mssql/connection-manager.js:138:17)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at ConnectionManager._connect ([omitted]]backend/src/node_modules/sequelize/src/dialects/abstract/connection-manager.js:326:24)
at [omitted]]backend/src/node_modules/sequelize/src/dialects/abstract/connection-manager.js:250:32
at ConnectionManager.getConnection ([omitted]]backend/src/node_modules/sequelize/src/dialects/abstract/connection-manager.js:280:7)
at [omitted]]backend/src/node_modules/sequelize/src/sequelize.js:629:26
at Name2Service.getMessage ([omitted]]backend/src/src/app/app.service.ts:105:34)
at bootstrapFactory ([omitted]]backend/src/src/common/common.utils.ts:42:5) {
parent: ConnectionError: Failed to connect to {sql_server_address}:1433 - socket hang up
at Connection.socketError ([omitted]]backend/src/node_modules/tedious/src/connection.ts:2222:28)
at Connection.socketEnd ([omitted]]backend/src/node_modules/tedious/src/connection.ts:2239:12)
at Socket.<anonymous> ([omitted]]backend/src/node_modules/tedious/src/connection.ts:2013:37)
at Socket.emit (node:events:549:35)
at endReadableNT (node:internal/streams/readable:1359:12)
at processTicksAndRejections (node:internal/process/task_queues:82:21) {
code: 'ESOCKET',
isTransient: undefined
},
original: ConnectionError: Failed to connect to {sql_server_address}:1433 - socket hang up
at Connection.socketError ([omitted]]backend/src/node_modules/tedious/src/connection.ts:2222:28)
at Connection.socketEnd ([omitted]]backend/src/node_modules/tedious/src/connection.ts:2239:12)
at Socket.<anonymous> ([omitted]]backend/src/node_modules/tedious/src/connection.ts:2013:37)
at Socket.emit (node:events:549:35)
at endReadableNT (node:internal/streams/readable:1359:12)
at processTicksAndRejections (node:internal/process/task_queues:82:21) {
code: 'ESOCKET',
isTransient: undefined
}
}
Configuration:
The connection is handled by sequelize.
{
username: '[OMITTED]',
password: '{OMITTED]',
host: '{OMITTED]',
logging: true,
}
I have tried passing recommended options but to no avail.
options: {
keepAlive: true,
encrypt: true,
enableArithAbort: true,
}
As previously mentioned: this works fine up to Node v16
Software versions
- NodeJS: 18.4.0
- node-mssql: 8.1.2
- tedious: 14.5.x | 14.6.x
- sequelize: 6.20.1
- SQL Server: SQL Server 2016 Service Pack 1 CU11 (13.0.4528.0)
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:33 (5 by maintainers)
Top Results From Across the Web
NodeJS - What does "socket hang up" actually mean?
It means that socket does not send connection end event within the timeout period. If you are getting the request for cheerio via...
Read more >ESOCKET Connection lost - socket hang up #1035 - GitHub
I'm trying to connect node with database and ended up with this error ... { message: 'Connection lost - socket hang up', code:...
Read more >How to handle a socket hang up error in Node.js usually - Quora
Close the connection if you have opened any for connecting to database after your work is done. Most of the times this is...
Read more >NodeJS - What does socket hang up actually mean - Edureka
When you're a customer, When you send a request to a distant server as a client and don't get a response in a...
Read more >[Error: socket hang up] code: 'ECONNRESET' - Google Groups
Re: [nodejs] NodeJS - { [Error: socket hang up] code: 'ECONNRESET' } ... usually the connection reset is caused by your own server...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Actually, I now found a way to workaround this, but I’d only use it if there’s really no way to get a more secure certificate installed:
Any other security level higher than
0does change the list ofsigalgsthat are sent by OpenSSL in a way that makes the TLS connection fail.Hey @arthurschreiber,
I found a relatively simple way to reproduce using an AWS EC2 instance:
npm install tedious, then runnode .This will succeed (return rows) for node 16.18.0 (latest), and an error for node 17 and later, here is the error I got on node 17.0.0