Skip to content

Commit 2df59d7

Browse files
asambstackfrancisf
authored andcommitted
fix: close outgoing socket with same code as incoming socket
1 parent 723edb4 commit 2df59d7

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

lib/core/Context.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class Context extends EventEmitter {
134134
);
135135
this.outgoingSocket.emit(kQueueMessage);
136136
this.upstreamCloseTimer = setTimeout(
137-
this.closingOutgoingSocket.bind(this),
137+
this.closingOutgoingSocket.bind(this, code, msg),
138138
config.closeTimer
139139
);
140140
incrClosedConnectionCount();
@@ -243,8 +243,8 @@ class Context extends EventEmitter {
243243
/**
244244
* Closes outgoing socket and emits clean up event.
245245
*/
246-
closingOutgoingSocket() {
247-
this.outgoingSocket.close();
246+
closingOutgoingSocket(code, msg) {
247+
this.outgoingSocket.close(code, msg);
248248
this.emit(kCleanup, this.connectionId);
249249
}
250250

lib/core/OutgoingWebSocket.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,13 @@ class OutgoingWebSocket extends EventEmitter {
163163
/**
164164
* Closes the socket connection.
165165
*/
166-
close() {
167-
this.socket.close();
166+
close(code, msg) {
167+
if(code == 1006)
168+
this.socket.terminate();
169+
else if(code == 1005)
170+
this.socket.close();
171+
else
172+
this.socket.close(code, msg);
168173
}
169174

170175
/**

0 commit comments

Comments
 (0)