Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Failed to connect" with encryption enabled on node v12.14.1 #1287

Closed
torywheelwright opened this issue Aug 2, 2021 · 2 comments
Closed

Comments

@torywheelwright
Copy link

torywheelwright commented Aug 2, 2021

Expected behaviour:

The client would establish a connection successfully when encrypted: true is used.

Actual behaviour:

The client is disconnected, which results in this stack trace at the client:

ConnectionError: Failed to connect to <redacted> - socket hang up
    at Connection.<anonymous> (/app/node_modules/mssql/lib/tedious.js:244:17)
    at Object.onceWrapper (events.js:313:26)\n    at Connection.emit (events.js:223:5)
    at Connection.socketError (/app/node_modules/tedious/lib/connection.js:1095:12)
    at Connection.socketEnd (/app/node_modules/tedious/lib/connection.js:1118:12)
    at Socket.<anonymous> (/app/node_modules/tedious/lib/connection.js:977:14)
    at Socket.emit (events.js:228:7)\n    at endReadableNT (_stream_readable.js:1185:12)
    at processTicksAndRejections (internal/process/task_queues.js:81:21)

On the server, we got this error for the first through third connection attempts:

Error: 17832, Severity: 20, State: 2.
The login packet used to open the connection is structurally invalid; the connection has been closed. Please contact the vendor of the client library. [CLIENT: <redacted>]

On the fourth attempt, we got this error:

Error: 17836, Severity: 20, State: 17.
Length specified in network packet payload did not match number of bytes read; the connection has been closed. Please contact the vendor of the client library. [CLIENT: <redacted>]

This issue began manifesting when we upgraded from node 12.13.1 -> 12.14.1. We've only seen it manifest against this one database, which unfortunately is a third party system that I don't have direct access to. It only manifests when encrypted is set to true. I tried provisioning the closest-versioned RDS instance that's available (Microsoft SQL Server 2016 (SP2-CU11) (KB4527378) - 13.0.5598.27 (X64)), but wasn't able to make the issue manifest against that server either. This appears very similar in nature to (now closed) upstream tediousjs/tedious#923. Based on that, as well as the stack trace, I think this probably belongs upstream in the tedious project, but thought it best to report here first.

Configuration:

new mssql.ConnectionPool({
  database: '',
  password: '<redacted>',
  port: 1433,
  server: '<redacted>',
  user: '<redacted>',
  options: { encrypt: true, trustServerCertificate: true }
});

Software versions

  • NodeJS: 12.14.1
  • node-mssql: 7.1.3
  • SQL Server: Microsoft SQL Server 2016 (SP2-CU12) (KB4536648) - 13.0.5698.0 (X64)

Tedious resolved to 11.3.0 as per yarn.lock.

@torywheelwright torywheelwright changed the title "Failure to connect" with encryption enabled on node v12.14.1 "Failed to connect" with encryption enabled on node v12.14.1 Aug 2, 2021
@dhensby
Copy link
Collaborator

dhensby commented Aug 3, 2021

Interesting, as the logic and code for the login packets belongs in the tedious driver, it's not something that I think it directly to do with this library (as you point out). I think it should be opened there.

It might be worth checking if this issue manifests itself when using the tedious driver directly.

@dhensby
Copy link
Collaborator

dhensby commented Nov 3, 2021

closing as upstream issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants