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

reduce Mongo db connection retry warnings

only report on first attempt
to close issue 1052 on main project
This commit is contained in:
Dave Conway-Jones 2016-11-16 22:48:41 +00:00
parent 5c1edc641a
commit 7a39c6f70b
2 changed files with 9 additions and 4 deletions

View File

@ -35,7 +35,6 @@ module.exports = function(RED) {
return selector;
}
function MongoOutNode(n) {
RED.nodes.createNode(this,n);
this.collection = n.collection;
@ -47,16 +46,19 @@ module.exports = function(RED) {
this.mongoConfig = RED.nodes.getNode(this.mongodb);
this.status({fill:"grey",shape:"ring",text:RED._("mongodbstatus.connecting")});
var node = this;
var noerror = true;
var connectToDB = function() {
MongoClient.connect(node.mongoConfig.url, function(err, db) {
if (err) {
node.status({fill:"red",shape:"ring",text:RED._("mongodb.status.error")});
node.error(err);
if (noerror) { node.error(err); }
noerror = false;
node.tout = setTimeout(connectToDB, 10000);
} else {
node.status({fill:"green",shape:"dot",text:RED._("mongodb.status.connected")});
node.clientDb = db;
noerror = true;
var coll;
if (node.collection) {
coll = db.collection(node.collection);
@ -162,16 +164,19 @@ module.exports = function(RED) {
this.mongoConfig = RED.nodes.getNode(this.mongodb);
this.status({fill:"grey",shape:"ring",text:RED._("mongodb.status.connecting")});
var node = this;
var noerror = true;
var connectToDB = function() {
MongoClient.connect(node.mongoConfig.url, function(err,db) {
if (err) {
node.status({fill:"red",shape:"ring",text:RED._("mongodb.status.error")});
node.error(err);
if (noerror) { node.error(err); }
noerror = false;
node.tout = setTimeout(connectToDB, 10000);
} else {
node.status({fill:"green",shape:"dot",text:RED._("mongodb.status.connected")});
node.clientDb = db;
noerror = true;
var coll;
if (node.collection) {
coll = db.collection(node.collection);

View File

@ -1,6 +1,6 @@
{
"name" : "node-red-node-mongodb",
"version" : "0.0.10",
"version" : "0.0.11",
"description" : "Node-RED nodes to talk to an Mongo database",
"dependencies" : {
"mongodb" : "^2.2.11"