Azure SQL Databaseμ ν μ΄λΈμ΄ μμ΅λλ€.
CREATE TABLE [dbo].[Owner](
[OwnerId] [int] IDENTITY(1,1) NOT NULL PRIMARY KEY,
[Name] [varchar](50) NOT NULL,
[Signature] [varchar](max) NULL
)
μλͺ μ΄μ λ§€μ° κΈ΄ λ¬Έμμ΄μ μ½μ νλ €κ³ νμ΅λλ€. packetSizeκ° 16384 μ΄μμΌλ‘ μ€μ λμ΄ μμ§ μμΌλ©΄ λ€μ μμΈκ° λ°μν©λλ€.
ConnectionError: Connection lost - write ECONNRESET
at ConnectionError (C:\work\GitRepos\tedious-test\node_modules\tedious\lib\errors.js:13:12)
at Connection.socketError (C:\work\GitRepos\tedious-test\node_modules\tedious\lib\connection.js:1187:26)
at Socket.<anonymous> (C:\work\GitRepos\tedious-test\node_modules\tedious\lib\connection.js:1032:14)
at Socket.emit (events.js:205:15)
at errorOrDestroy (internal/streams/destroy.js:107:12)
at onwriteError (_stream_writable.js:438:5)
at onwrite (_stream_writable.js:459:5)
at internal/streams/destroy.js:49:7
at Socket._destroy (net.js:593:3)
at Socket.destroy (internal/streams/destroy.js:37:8)
Emitted 'error' event at:
at Connection.socketError (C:\work\GitRepos\tedious-test\node_modules\tedious\lib\connection.js:1187:12)
at Socket.<anonymous> (C:\work\GitRepos\tedious-test\node_modules\tedious\lib\connection.js:1032:14)
[... lines matching original stack trace ...]
at Socket.destroy (internal/streams/destroy.js:37:8)
at WriteWrap.onWriteComplete [as oncomplete] (internal/stream_base_commons.js:84:12) {
message: 'Connection lost - write ECONNRESET',
code: 'ESOCKET'
}
μλλ λ΄ κ°λ¨ν ν μ€νΈ νλ‘κ·Έλ¨μ λλ€. λλ μ΅μ μ§λ£¨νμ μ¬μ©ν©λλ€. λν μ½κΈ° μμ μ ν¨ν· ν¬κΈ°μ κ΄κ³μμ΄ κΈ΄ λ¬Έμμ΄μ λν΄ μ μλνλ κ² κ°μ΅λλ€. λ΄κ° λ μλͺ»νλμ§ μμ?
var Connection = require('tedious').Connection;
var config = {
server: "myserver.database.windows.net",
options: {
encrypt: true,
database: "<mydb>",
packetSize: 4096,
},
authentication: {
type: "default",
options: {
userName: "<myuser>",
password: "<mypwd>",
}
}
};
var connection = new Connection(config);
connection.on('connect', function(err) {
// executeStatement();
executeInsert();
}
);
var Request = require('tedious').Request;
function executeStatement() {
/* Read a long string, work fine */
request = new Request("select OwnerId, Signature From dbo.Owner Where OwnerId = 36", function(err, rowCount) {
if (err) {
console.log(err);
} else {
console.log(rowCount + ' rows');
}
});
request.on('row', function(columns) {
columns.forEach(function(column) {
console.log(column.value);
});
});
connection.execSql(request);
}
function executeInsert() {
/************************************************
* Insert a long string, not working when
* packetSize = 4096
* If
* packetSize = 16384
* or higher, insertion works fine.
*****************************************************/
let s = '0123456789'.repeat(100000);
request = new Request("Insert into dbo.Owner VALUES ('Rick', '" + s + "')", function(err, rowCount) {
if (err) {
console.log(err);
} else {
console.log(rowCount + ' rows');
}
});
connection.execSql(request);
}
λΉμ·ν λ¬Έμ κ° λ°μν©λλ€. κΈ΄ λ¬Έμμ΄μ μ½μ
νλ €κ³ ν λ. μ½κ°μ ν
μ€νΈ νμ μ°λ¦¬μ κ²½μ° dockerized λ μ¬μ© λ nodejs λ²μ κ³Ό κ΄λ ¨μ΄ μμμ΄ λ°νμ‘μ΅λλ€.
node:10-slim -> μ μλν©λλ€.
λ
Έλ:12.3.1 -> μ μλν©λλ€.
node:12.4 λ₯Ό μμνλ©΄ μμΌ μ€λ¨ λλ μμΌ λ«ν μ€λ₯κ° λ°μν©λλ€.
μλ
νμΈμ @ricklang , μ λ μ΄κ²μ μ°Ύκ³ μμμ΅λλ€. "encrypt: true"κ° νμ μ€μ μ
λκΉ? κ·Έλ μ§ μμ κ²½μ° falseλ‘ μ€μ νκ±°λ κΈ°λ³Έκ° -falseλ₯Ό μ¬μ©νμ¬ μ΄λ¬ν λ¬Έμ λ₯Ό ν΄κ²°ν μλ μλ μ΅μ
μμ μ€μ νμ§ λ§μμμ€. μ μ΄λ° μΌμ΄ λ°μνλμ§ μμ λ΄λ €κ³ λ
Έλ ₯νμ§λ§ μ΄κ²μ κ·Όλ³Έ μμΈμ μ°Ύμ§ λͺ»νμ΅λλ€. μνΈν μ°κ²°κ³Ό λΉμνΈν μ°κ²° λͺ¨λμ λν΄ ν¨ν·μ νμΈνλλ° ν¨ν·μ΄ μ νν λμΌνμ§λ§ νλλ₯Ό μνΈννλ κ²½μ° EOMμ΄ μλ λ§μ§λ§ ν¨ν·μ μμ ν λ μ°κ²° λκΉ μ€λ₯κ° μμ λ©λλ€. μ‘°κΈ λ μ‘°μ¬ν΄ λ³΄κ² μ΅λλ€. νν€μΉ μ μλ κ²μ΄ μλμ§ νμΈνκ² μ΅λλ€.
λ€λ₯Έ ννΈμΌλ‘λ μ΄μ λν΄ @arthurschreiber μκ² λ¬Όμ΄λ³Ό μλ μμ΅λλ€. κ·Έμκ² ν΅μ°°λ ₯μ΄ μλμ§ νμΈνμμμ€.
μ ν¨κ»
encrypt: false,
μ€λ₯ λ©μμ§λ (ν¨ν· ν¬κΈ°μ κ΄κ³μμ΄):
RequestError: Requests can only be made in the LoggedIn state, not the SentPrelogin state
at RequestError (C:\work\GitRepos\tedious-test\node_modules\tedious\lib\errors.js:32:12)
at Connection.makeRequest (C:\work\GitRepos\tedious-test\node_modules\tedious\lib\connection.js:1680:24)
at Connection.execSql (C:\work\GitRepos\tedious-test\node_modules\tedious\lib\connection.js:1459:10)
at executeInsert (C:\work\GitRepos\tedious-test\index.js:67:14)
at Connection.<anonymous> (C:\work\GitRepos\tedious-test\index.js:24:5)
at Connection.emit (events.js:200:13)
at Connection.message (C:\work\GitRepos\tedious-test\node_modules\tedious\lib\connection.js:1871:18)
at Connection.dispatchEvent (C:\work\GitRepos\tedious-test\node_modules\tedious\lib\connection.js:1172:36)
at MessageIO.<anonymous> (C:\work\GitRepos\tedious-test\node_modules\tedious\lib\connection.js:1045:14)
at MessageIO.emit (events.js:200:13) {
message: 'Requests can only be made in the ' +
'LoggedIn state, not the SentPrelogin ' +
'state',
code: 'EINVALIDSTATE'
μνΈν μ€μ μ μ κ±°νκ³ ν¨ν· ν¬κΈ°λ₯Ό 4096μΌλ‘ λλ©΄ μ€λ₯ λ©μμ§λ λ€μκ³Ό κ°μ΅λλ€.
ConnectionError: Connection lost - write ECONNRESET
at ConnectionError (C:\work\GitRepos\tedious-test\node_modules\tedious\lib\errors.js:13:12)
at Connection.socketError (C:\work\GitRepos\tedious-test\node_modules\tedious\lib\connection.js:1187:26)
at Socket.<anonymous> (C:\work\GitRepos\tedious-test\node_modules\tedious\lib\connection.js:1032:14)
at Socket.emit (events.js:205:15)
at errorOrDestroy (internal/streams/destroy.js:107:12)
at onwriteError (_stream_writable.js:438:5)
at onwrite (_stream_writable.js:459:5)
at internal/streams/destroy.js:49:7
at Socket._destroy (net.js:593:3)
at Socket.destroy (internal/streams/destroy.js:37:8)
Emitted 'error' event at:
at Connection.socketError (C:\work\GitRepos\tedious-test\node_modules\tedious\lib\connection.js:1187:12)
at Socket.<anonymous> (C:\work\GitRepos\tedious-test\node_modules\tedious\lib\connection.js:1032:14)
[... lines matching original stack trace ...]
at Socket.destroy (internal/streams/destroy.js:37:8)
at WriteWrap.onWriteComplete [as oncomplete] (internal/stream_base_commons.js:84:12) {
message: 'Connection lost - write ECONNRESET',
code: 'ESOCKET'
κ·Έλ¬λ μνΈνλ₯Ό μ€μ νμ§ μκ³ ν¨ν· ν¬κΈ°λ₯Ό 16384λ‘ λ리면 λͺ¨λ κ²μ΄ μ λλ‘ μλν©λλ€.
그건 κ·Έλ κ³ , λλ λ Έλ λ²μ μ ν μ€νΈνμ΅λλ€: 12.4.0, 12.6.0. κ°μ κ²°κ³Όμ λλ€.
κΈ΄ 쿼리λ₯Ό μ€νν λ Connection lost - read ECONNRESET
λ₯Ό λ°μμ΅λλ€. encrypt: true
λ° packetSize: 32768
νλ©΄ λͺ¨λ κ²μ΄ μ μλν©λλ€.
λ
Έλ λ²μ : v12.6.0
@ wy193777 μΆκ° μ΅μ μμ΄ μ΅λ 12.3.1μμ λ Έλ λ²μ μ μ¬μ©νμ¬ λͺ¨λ κ²μ΄ μλνλμ§ νμΈν μ μμ΅λκΉ?
@susares λ Έλ v12.3.1μ packetSize μ΅μ μμ΄ μλν©λλ€.
λ
Έλ λ²μ : v12.2.0μ packetSize μ΅μ
μμ΄ μλν©λλ€.
λ
Έλ λ²μ : v.12.6.0μμ Connection lost - read ECONNRESET
μ€λ₯λ₯Ό νΌνκΈ° μν΄ packetSize: 8192
λ₯Ό μ¬μ©ν΄μΌ νμ΅λλ€.
μ΄κ²μ https://github.com/nodejs/node/pull/27861 λλ¬ΈμΈ κ² κ°μ΅λλ€. μ΄μ¨λ ν° TLS μΈκ·Έλ¨ΌνΈκ° μμ±λλ©΄ SQLServerκ° μ°κ²°μ μ’ λ£ν©λλ€. λλ μμ μ¬νμ΄ μμΌλ©° 곧 PRμ μ΄ κ²μ λλ€. π
κΈ°λ€λ¦΄ μ μλ μ¬λλ€μ μν΄ μ΄ λ¬Έμ λ₯Ό ν΄κ²°ν diffκ° μμ΅λλ€.
diff --git a/src/message-io.js b/src/message-io.js
index 90875f8..79f5da8 100644
--- a/src/message-io.js
+++ b/src/message-io.js
@@ -72,6 +72,8 @@ module.exports = class MessageIO extends EventEmitter {
encrypted: duplexpair.socket2
};
+ securePair.cleartext.setMaxSendFragment(this.outgoingMessageStream.packetSize);
+
// If an error happens in the TLS layer, there is nothing we can do about it.
// Forward the error to the socket so the connection gets properly cleaned up.
securePair.cleartext.on('error', (err) => {
:tada: μ΄ λ¬Έμ λ λ²μ 6.2.1μμ ν΄κ²°λμμ΅λλ€.
릴리μ€λ λ€μμμ μ¬μ©ν μ μμ΅λλ€.
μλ§¨ν± λ¦΄λ¦¬μ€ λ΄ :package::rocket:
κ°μ₯ μ μ©ν λκΈ
κΈ΄ 쿼리λ₯Ό μ€νν λ
Connection lost - read ECONNRESET
λ₯Ό λ°μμ΅λλ€.encrypt: true
λ°packetSize: 32768
νλ©΄ λͺ¨λ κ²μ΄ μ μλν©λλ€.λ Έλ λ²μ :
v12.6.0