Fix for #2498
Ylian Saint-Hilaire committed
Apr 12, 2021 at 15:27 UTC
fd5eb3efca23481c34fffc01ad2c0a40987e537f
1 file changed
+6
-1
amt/amt-wsman-comm.js
+6
-1
@@ -452,7 +452,12 @@ var CreateWsmanComm = function (host, port, user, pass, tls, tlsoptions, mpsConn
452
//obj.Debug("xxOnSocketClosed");
453
obj.socketState = 0;
454
if (obj.socket != null) {
455
- if (obj.socket.removeAllListeners) { obj.socket.removeAllListeners(); }
455
+ if (obj.socket.removeAllListeners) {
456
+ // Do not remove the error handler since it may still get triggered.
457
+ obj.socket.removeAllListeners('data');
458
+ obj.socket.removeAllListeners('close');
459
+ obj.socket.removeAllListeners('timeout');
460
+ }
461
try {
462
if (obj.mpsConnection == null) {
463
obj.socket.destroy();