restart a single node , possible ?

1,352 views
Skip to first unread message

magouero

unread,
Feb 28, 2017, 11:47:20 AM2/28/17
to Node-RED
Gentlemen,



I experience a problem where a node , when it starts , begins with establishing a connection with a radio card.

It happens that the link is sometimes not established and then no message comes out of this node.

I noticed that if i make a small modification  to something in the same flow and ask "deploy full" or "modified flow" it +/- restarts the nodes and that corrects the bug i have.
Whereas deploy "modofoed nodes" does not correct because it does not ask for the node to restart.

I cannot modifiy the node by myself because i'm not enough good at using JS and it is not my product so supplier should do that.



So my question is:
is there a way to ask nodered to restart 1 node while keeping the rest as it is, (because the rest is running and ok). I mean: have that particular node go through the same steps than at the nodered deploy step ?
e.g. using a exec node launching a command for node.js to do sometthing like stop/start this node ?

Sorry if it looks like a stupid question but i think it is interesting to understand a bit how it works "inside".




Thanks for your answers.










Nick O'Leary

unread,
Mar 1, 2017, 3:56:05 AM3/1/17
to Node-RED Mailing List
Hi,

the 'modified nodes' deploy type does not refer to node whose source code has been modified. It means the nodes who have undeployed changes in your workspace. A change can be as simple as the node having been moved. So to restart a single node, move it in the workspace, then hit deploy.

Nick

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/8129483a-e197-4086-890a-4cdcaa8796e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

magouero

unread,
Mar 1, 2017, 7:55:10 AM3/1/17
to Node-RED
Hello Nick,
thank you for the answer but that is not what i need.

I want to know if, with a node red node or using linux command via a exec node  i can restart or redeploy 1 node and not the total canvas. because i have a node that is not responding.
i know that if i make a change somewhere and hit deploy it makes the problem disappear. But i cannot do this tyope of action because for that i need to be plugged to my equipment, not possible, and it will also redeploy all the rest that is already working.




Le mercredi 1 mars 2017 09:56:05 UTC+1, Nick O'Leary a écrit :
Hi,

the 'modified nodes' deploy type does not refer to node whose source code has been modified. It means the nodes who have undeployed changes in your workspace. A change can be as simple as the node having been moved. So to restart a single node, move it in the workspace, then hit deploy.

Nick
On 28 February 2017 at 16:47, magouero <pend...@gmail.com> wrote:
Gentlemen,



I experience a problem where a node , when it starts , begins with establishing a connection with a radio card.

It happens that the link is sometimes not established and then no message comes out of this node.

I noticed that if i make a small modification  to something in the same flow and ask "deploy full" or "modified flow" it +/- restarts the nodes and that corrects the bug i have.
Whereas deploy "modofoed nodes" does not correct because it does not ask for the node to restart.

I cannot modifiy the node by myself because i'm not enough good at using JS and it is not my product so supplier should do that.



So my question is:
is there a way to ask nodered to restart 1 node while keeping the rest as it is, (because the rest is running and ok). I mean: have that particular node go through the same steps than at the nodered deploy step ?
e.g. using a exec node launching a command for node.js to do sometthing like stop/start this node ?

Sorry if it looks like a stupid question but i think it is interesting to understand a bit how it works "inside".




Thanks for your answers.










--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.

Sebastian Barwe

unread,
Mar 1, 2017, 9:39:02 AM3/1/17
to Node-RED
Are you reffering to exec nodes? then you may put in some kind of process-monitor which tracks the process if it is working or not and that will auto-recover if it doesnt 

Or you could use the Admin API ... get The Flow Config, change the node (e.g. by toggling a byte in the name of the node or something like that) and deploy it again with
  1. Node-RED-Deployment-Type:
    nodes
set in the http-request-headers. You could do this even within node-red itself. With using authentication of course you have a little more work todo

Colin Law

unread,
Mar 1, 2017, 9:44:05 AM3/1/17
to node...@googlegroups.com
I presume you have fed the issue back to the supplier. Was he not able
to help with fixing it?

Colin

On 28 February 2017 at 16:47, magouero <pend...@gmail.com> wrote:

Colin Law

unread,
Mar 1, 2017, 9:46:10 AM3/1/17
to node...@googlegroups.com
Not a solution to your problem, but what you say is not correct. If
you modify just that node and then deploy, telling it to deploy only
modified nodes, then it will not restart the whole flow, just that
node.

Colin
> https://groups.google.com/d/msgid/node-red/12f6a209-c5e6-44b0-8b23-2e5df75e5f91%40googlegroups.com.

Greg Gregory

unread,
Mar 3, 2017, 4:48:41 PM3/3/17
to Node-RED
I have same problem with different node, looking for answer as well. In my case the point is to have node like status node with inject option which can interact with selected node and be able to lets say put this node in disconnect mode and then connect again. When i restart nodered then my node trying to reconnect and then sometimes it stay in searching or connecting mode. so it would be nice to have node which could interact with that node and from the dashboard i could restart that node. Im not advanced programmer, so it is really hard to me how to manage this problem from dashboard. I was looking for option like to use exec node node to put command for nodejs to stopped that node but I cant find the solution. Maybe someone here could help me, if I want to start node using nodejs I use command NODE MYNODE.JS so can I use similarly command to stop node from nodered flow?
Thanks in advace  

Colin Law

unread,
Mar 3, 2017, 5:03:21 PM3/3/17
to node...@googlegroups.com
Do you mean there is a bug in the node that means it does not
automatically reconnect properly?

Colin
> --
> http://nodered.org
>
> Join us on Slack to continue the conversation: http://nodered.org/slack
> ---
> You received this message because you are subscribed to the Google Groups
> "Node-RED" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to node-red+u...@googlegroups.com.
> To post to this group, send email to node...@googlegroups.com.
> Visit this group at https://groups.google.com/group/node-red.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/node-red/384830c9-c108-437a-9108-8c165777c970%40googlegroups.com.

Greg Gregory

unread,
Mar 3, 2017, 5:21:27 PM3/3/17
to Node-RED
I think it maybe/definitely is  that node what I use .

Colin Law

unread,
Mar 3, 2017, 5:26:25 PM3/3/17
to node...@googlegroups.com
The best thing would be to get the bug fixed then. Which node is it?

Colin
> https://groups.google.com/d/msgid/node-red/6beaa2d3-5377-4155-ada1-bf26ab0036fe%40googlegroups.com.

Greg Gregory

unread,
Mar 3, 2017, 5:31:00 PM3/3/17
to Node-RED
it is serial node for lightblue bean sensor the problem is that author is not supporting it now as it state on them website. Node is connecting to sensor using BLE so it maybe the bluetooth module used by raspberry pi 3 I just guessing as I have no idea,

magouero

unread,
Mar 4, 2017, 11:46:08 AM3/4/17
to Node-RED
Of course but this the supplier's job. Paid for that. And for the moment not reacting.
But meanwhile, understanding how system works could help finding a solution.

So the question was : is there a way to restart a node using a command, whatever it is?
The command cannot be deploy because it will restar the rest.

Colin Law

unread,
Mar 4, 2017, 11:57:39 AM3/4/17
to node...@googlegroups.com
Do you need to do it from the flow, or manually?

Colin
> --
> http://nodered.org
>
> Join us on Slack to continue the conversation: http://nodered.org/slack
> ---
> You received this message because you are subscribed to the Google Groups "Node-RED" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
> To post to this group, send an email to node...@googlegroups.com.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/b434d803-29a5-4b9a-ac10-fa602f20f15a%40googlegroups.com.

Colin Law

unread,
Mar 5, 2017, 4:05:36 AM3/5/17
to node...@googlegroups.com
Also, if you tell us where to find this node it might be simple to add
a restart function to it so you can do it in the flow by sending a
message with topic 'reset' or something. It depends on how complex
the code is.

Colin
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

magouero

unread,
Mar 5, 2017, 6:23:00 AM3/5/17
to Node-RED
I need to to it from the flow as the equipment is not accessible.
I thought to this:
Elsewhere in the flow: (inject node) --> (delay ~3s) --> (reset/redeploy the buggy node and only this one)

So when all the flow start, this buggy node is restarted some seconds after the rest and then it is ok.

Below is the code of the node.

If you can guide me to understand how the modfication for reset works.

Thanks.

§§§§§§§
module.exports = function(RED) {
  "use strict";
  var compatableMcardIDs = ['MTAC-LORA-915', 'MTAC-LORA-868'];
  var mqtt = require('mqtt');
  var mqttServer = "mqtt://127.0.0.1'";
  var Mcard = require('mts-mcard');

  function setStatus(node, status) {
    switch (status) {
      case "checking": node.status({fill:"grey",shape:"dot",text:"checking mCard"}); break;
      case "connecting": node.status({fill:"grey",shape:"dot",text:"connecting"}); break;
      case "connected": node.status({fill:"green",shape:"dot",text:"connected"}); break;
      case "disconnected": node.status({fill:"red",shape:"ring",text:"disconnected"}); break;
      case "error": node.status({fill:"red",shape:"ring",text:"ERROR-MQTT CONNECT"}); break;
      case "incompatable": node.status({fill:"red",shape:"ring",text:"INCOMPATABLE MCARD"}); break;
      case "nocard": node.status({fill:"red",shape:"ring",text:"NO MCARD"}); break;
      default: node.status({}); break;
    }
  }

  function VerifyMcardThenSetupWith(node, config, setupCallback) {
    Mcard.compatableProductIdPresent(compatableMcardIDs, function(result) {
      node.log('mcard: ' + result);
      if (result == true) {
        setStatus(node, "connecting");
        setupCallback(node, config);
      }
      else {
        setStatus(node, "incompatable");
        node.error('Lora mCard not found. Compatable mCards: ' + compatableMcardIDs);
      }
    });
  }


  function LoraInNode(config) {
    RED.nodes.createNode(this, config);
    var node = this;

    setStatus(node, "checking");
    VerifyMcardThenSetupWith(node, config, SetupLoraInNode);

    node.log("lora in node created");
  }

  function SetupLoraInNode(node, config) {
    var mqttTopic = 'lora/+/up';
    var client = mqtt.connect(mqttServer).on('error', function(error) {
      node.error("LoRa in node MQTT error: " + error);
      setStatus(node, "error");
    }).on('connect', function() {
      node.log("Connected to MQTT for LoRa in node.");
      setStatus(node, "connected");
    });
    client.subscribe(mqttTopic);

    client.on('message', function(topic, message) {
      var arr = topic.split("/");
      var obj = JSON.parse(message);
      var data;
      if (config.datatype === "utf8") {
        data = new Buffer(obj.data, 'base64').toString('utf-8');
      } else if (config.datatype === "bytes") {
        data = new Buffer(obj.data, 'base64');
      } else {
        node.error("Invalid datatype.");
        return;
      }
      if (obj.data) { // moving the data to the payload for use in Node-RED
        obj.payload = data;
        delete obj.data;
      }
      obj.eui = arr[1];
      node.send(obj);
    });
    node.on("close", function() {
      node.log("LoRa in node closing...");
      setStatus(node, "disconnected");
      client.end();
    });
  }

  RED.nodes.registerType("lora in", LoraInNode);

  function LoraOutNode(config) {
    RED.nodes.createNode(this, config);
    var node = this;

    setStatus(node, "checking");
    VerifyMcardThenSetupWith(node, config, SetupLoraOutNode);

    node.log("lora out node created");
  }

  function SetupLoraOutNode(node, config) {
    var client = mqtt.connect(mqttServer).on('error', function(error) {
      node.error("LoRa out node MQTT error: " + error);
      setStatus(node, "error");
    }).on('connect', function() {
      node.log("Connected to MQTT for LoRa out node.");
      setStatus(node, "connected");
    });
    node.on('input', function(msg) {
      var eui = msg.eui || config.eui;
      var payload = msg.payload || config.payload;
      var ack_config = msg.ack || config.ack;
      var port_config = msg.port || config.port;
      if (payload instanceof Buffer || typeof(payload) === "string" ) {
        var msg = { data: new Buffer(payload).toString("base64"), ack: ack_config, port: port_config };
        client.publish('lora/' + eui + '/down', JSON.stringify(msg));
        node.log("Published downstream lora packet");
      } else {
        node.error("Invalid data type in message payload: " + typeof payload + ".  Expected String or Buffer.");
        return;
      }

    });
    node.on("close", function() {
      node.log("LoRa out node closing...");
      setStatus(node, "disconnected");
      client.end();
    });
  }

  RED.nodes.registerType("lora out", LoraOutNode);

};


§§§§§§§

Colin Law

unread,
Mar 5, 2017, 6:43:42 AM3/5/17
to node...@googlegroups.com
Is the node not in npm?

I see it logs stuff as it is going along. Are you seeing any messages
in the log or terminal when you get the problem. /var/log/syslog if it
is running as a service or in the terminal if you are running node red
manually.

Colin
> To post to this group, send email to node...@googlegroups.com.
> Visit this group at https://groups.google.com/group/node-red.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/node-red/576ff604-1843-4f4c-81f4-e301fc2afd5b%40googlegroups.com.
Message has been deleted

magouero

unread,
Mar 5, 2017, 1:44:53 PM3/5/17
to Node-RED
Not in npm, supplied in the equipment i use.

I can see some nodered logs using SSH.
At the moment i cannot cause i do not have a sensor to send frames but tomorrow i'll catch some logs when the bug is here , deploy then when it is not present. Maybe we'll catch a clue.

But let's not forget the objective: restart the node. Not correct the bug. This because it can also be linked to a HW problem (NR starting to fast or card not yet ready, ... can be a lot of things).

A log when i add the lora node linked to a debug node then "deploy full" (which +/-corrects the bug) , nothing weird:
5 Mar 19:36:39 - [info] Stopping flows
5 Mar 19:36:39 - [info] [udp in:msg Lora arrivant] udp listener stopped
5 Mar 19:36:39 - [info] Stopped flows
5 Mar 19:36:39 - [info] Starting flows
5 Mar 19:36:46 - [error] [mqtt in: a modifier !!!] missing broker configuration  --> this is normal, intentional
5 Mar 19:36:55 - [info] [lora in:97fb58f6.87b8e8] lora in node created
5 Mar 19:36:55 - [info] Started flows
5 Mar 19:36:56 - [info] [udp in:msg Lora arrivant] udp listener at 0.0.0.0:1784
5 Mar 19:36:56 - [info] [lora in:97fb58f6.87b8e8] mcard: true
5 Mar 19:36:56 - [info] [lora in:97fb58f6.87b8e8] Connected to MQTT for LoRa in node.


Colin Law

unread,
Mar 5, 2017, 3:23:35 PM3/5/17
to node...@googlegroups.com
On 5 March 2017 at 18:43, magouero <pend...@gmail.com> wrote:
> Not in npm, supplied in the equipment i use.
>
> I can see some nodered logs using SSH.
> At the moment i cannot cause i do not have a sensor to send frames but
> tomorrow i'll catch some logs when the bug is here , deploy then when it is
> not present. Maybe we'll catch a clue.
>
> But let's not forget the objective: restart the node. Not correct the bug.
> This because it can also be linked to a HW problem (NR starting to fast or
> card not yet ready, ... can be a lot of things).

That does not make sense. The objective should be to fix the bug. If
that cannot sensibly be achieved then find a workaround.

Colin

>
> A log when i add the lora node linked to a debug node then "deploy full"
> (which +/-corrects the bug) , nothing weird:
> 5 Mar 19:36:39 - [info] Stopping flows
> 5 Mar 19:36:39 - [info] [udp in:msg Lora arrivant] udp listener stopped
> 5 Mar 19:36:39 - [info] Stopped flows
> 5 Mar 19:36:39 - [info] Starting flows
> 5 Mar 19:36:46 - [error] [mqtt in: a modifier !!!] missing broker
> configuration --> this is normal, intentional
> 5 Mar 19:36:55 - [info] [lora in:97fb58f6.87b8e8] lora in node created
> 5 Mar 19:36:55 - [info] Started flows
> 5 Mar 19:36:56 - [info] [udp in:msg Lora arrivant] udp listener at
> 0.0.0.0:1784
> 5 Mar 19:36:56 - [info] [lora in:97fb58f6.87b8e8] mcard: true
> 5 Mar 19:36:56 - [info] [lora in:97fb58f6.87b8e8] Connected to MQTT for LoRa
> https://groups.google.com/d/msgid/node-red/0c103517-6e34-45f0-9c04-e7a7a2fe399d%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages