1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00

XMPP: improve debugging and error handling (#753)

This commit is contained in:
Andreas Martens 2021-02-02 16:55:55 +00:00 committed by GitHub
parent 7c96bffece
commit 1c34e39d8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -115,10 +115,14 @@ module.exports = function(RED) {
text = textObj.getText(); text = textObj.getText();
} }
} }
if (RED.settings.verbose || LOGITALL) {that.log("Culprit: "+that.lastUsed); } if (RED.settings.verbose || LOGITALL) {that.log("Culprit: "+that.lastUsed.id); }
if ("undefined" !== typeof that.lastUsed) { if ("undefined" !== typeof that.lastUsed) {
that.lastUsed.status({fill:"red",shape:"ring",text:text}); that.lastUsed.status({fill:"red",shape:"ring",text:text});
that.lastUsed.warn(text); that.lastUsed.warn(text);
if (that.lastUsed.join) {
// it was trying to MUC things up
clearMUC(that);
}
} }
if (RED.settings.verbose || LOGITALL) { if (RED.settings.verbose || LOGITALL) {
that.log("We did wrong: "+text); that.log("We did wrong: "+text);
@ -237,6 +241,13 @@ module.exports = function(RED) {
} }
} }
function clearMUC(config) {
//something has happened, so clear out our presence indicators
if (RED.settings.verbose || LOGITALL) {
config.log("cleared all MUC membership");
}
config.MUCs = {};
}
// separated out since we want the same functionality from both in and out nodes // separated out since we want the same functionality from both in and out nodes
function errorHandler(node, err){ function errorHandler(node, err){
if (!node.quiet) { if (!node.quiet) {
@ -250,8 +261,9 @@ module.exports = function(RED) {
} }
// The error might be a string // The error might be a string
else if (err == "TimeoutError") { else if (err == "TimeoutError") {
// OK, this happens with OpenFire, suppress it. // OK, this happens with OpenFire, suppress it, but invalidate MUC membership as it will need to be re-established.
node.status({fill:"grey",shape:"dot",text:"opening"}); clearMUC(node.serverConfig);
node.status({fill:"grey",shape:"dot",text:"TimeoutError"});
node.log("Timed out! ",err); node.log("Timed out! ",err);
// node.status({fill:"red",shape:"ring",text:"XMPP timeout"}); // node.status({fill:"red",shape:"ring",text:"XMPP timeout"});
} }
@ -271,7 +283,7 @@ module.exports = function(RED) {
node.status({fill:"red",shape:"ring",text:"timeout"}); node.status({fill:"red",shape:"ring",text:"timeout"});
} }
else if (err.errno === "ENOTFOUND") { else if (err.errno === "ENOTFOUND") {
node.error("Server doesn't exist "+xmpp.options.service,err); node.error("Server doesn't exist "+node.serverConfig.server,err);
node.status({fill:"red",shape:"ring",text:"bad address"}); node.status({fill:"red",shape:"ring",text:"bad address"});
} }
// nothing we've seen before! // nothing we've seen before!