Merge pull request #3428 from nzalev/bugfix-agent-disconnect

Fix null reference on agent disconnect
This commit is contained in:
Ylian Saint-Hilaire 2022-01-08 11:29:40 -08:00 committed by GitHub
commit 213f06658c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -58,7 +58,19 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
dataAccounting();
if ((arg == 1) || (arg == null)) { try { ws.close(); if (obj.nodeid != null) { parent.parent.debug('agent', 'Soft disconnect ' + obj.nodeid + ' (' + obj.remoteaddrport + ')'); } } catch (e) { console.log(e); } } // Soft close, close the websocket
if (arg == 2) { try { ws._socket._parent.end(); if (obj.nodeid != null) { parent.parent.debug('agent', 'Hard disconnect ' + obj.nodeid + ' (' + obj.remoteaddrport + ')'); } } catch (e) { console.log(e); } } // Hard close, close the TCP socket
if (arg == 2) {
try {
if (ws._socket._parent != null)
ws._socket._parent.end();
else
ws._socket.end();
if (obj.nodeid != null) {
parent.parent.debug('agent', 'Hard disconnect ' + obj.nodeid + ' (' + obj.remoteaddrport + ')');
}
} catch (e) { console.log(e); }
}
// If arg == 2, hard close, close the TCP socket
// If arg == 3, don't communicate with this agent anymore, but don't disconnect (Duplicate agent).
// Stop any current self-share