Modbus Flex Getter freezes flow when IP becomes invalid

Hi everyone,

I have node-red running at a factory. The flow uses four Modbus Flex Getter nodes to collect data from four different PLC's, each with it's own IP address that are mounted on industrial ovens.
Everything works great until someone at the factory turns off one of the PLC's. When that happens the entire flow "freezes". I believe this happens because the IP address listed in the Flex Getter node is suddenly no longer available. Node-red also does not automatically reconnect when the IP address becomes valid again, I have to press F5 on the keyboard to "unfreeze" the flow.

Here is the flow for oven 1.

Does anyone know of a fix or a work around to prevent node-red from freezing up when an IP is no longer valid? Maybe some sort of other node in front of the Flex Getter node?

node.js version 14.7.0
Node-red version 2.2.2
node-red-contrib-modbus version 5.23.3

Thank you,

1 Like

What do you mean by freezing? Do you mean that the browser is hung up or do you mean the flows stop? If the latter then how do you know that?

How are the other getter nodes connected?

Hitting F5 just refreshes the browser view, it will not have any effect on what is going on in node-red itself.

I'm running a very similar production type environment over MODBUS. I've quit using the flex-getter node in favor of using a sequencer node as you can setup the sequence of retrievals in the node itself and just trigger it with a timed injection node. That's helped things a little by itself because it's all managed by the node set and not me.

Also, Colin makes a really good question. What do you mean by freezing? I can unplug any of my MODBUS units from the network and all that happens is data goes silent for that span of time. When I plug it back in, it picks right back up and data begins streaming with no intervention on my part. The same should happen with your setup. The MODBUS node set is very robust in my opinion and it's only when I myself setup something incorrectly that I broke its functionality. It should be that when you start a new MODBUS query, it re-establishes any lost connections and goes.

One thing I have to also wonder about is if there's something in your setup that's hanging due to the lack of response. It's obvious there's only part of a flow there, so there could be more that is affected. I see two functions, but don't know what comes after. A question I do have, is there some reason the contents of both functions can't be housed in one? I'm not saying your problem is there, but I don't know. If there's something in one of those functions relying on a specific input that it's not getting (i.e. your MODBUS node outputs an error), it could cause an error in that function that doesn't recover. Not likely, but also not impossible.

One final thought is that perhaps your PLC is using DHCP for the IP address and it gets a new one when it's powered back on. This could cause the flow to lockup because it doesn't have the correct address. Though I don't know why it would pick back up when refreshing your browser.

Since it's commercial, I get you may not be able to show your whole flow. But anything more you can share will be helpful to getting this solved. And if you can export even one of the flows from beginning to end (i.e. the oven flow), that would be helpful too as we would be able to see not only the connections, but the internals you have setup as well.

Hi Colin, thanks for replying and I apologize for my delay in responding. I will be working on this project tomorrow now that Thanksgiving is over and I'm home again, I live thousands of miles from my family, and it took me a few days to get home.

I have some more information for you.

To answer your question, the flow simply stops. I know this because there is a delay node near the end of my flow that shows the number of seconds elapsed below the node. When the flow stops no number is displayed below the delay node. At the same time I know it's paused (or as I said originally - frozen), because no data is being inserted into the associated database. It simply stops.

Here's what I've learned so far,

If I remove a network cable from one of the PLC's the flow pauses, but restarts again after I plug the network cable back into the PLC, which is exactly what it should do, but, if I remove power to one of the PLC's the flow does not restart once I power it up again.

I will be answering the other people who responded to me over the next 24 hours, as I there are some suggestions I can try. I've got a couple of things I can try too. If you have any ideas as to why this might be happening please feel free to get in touch.

Thanks again for your time,

Kind regards,

When it is frozen can you communicate with the PLC from another modbus client?

If, when it is frozen, you unplug the network cable for a while, then plug it back in, does it recover?

If you unplug the network cable, power cycle the PLC then plug the cable back in does it recover?

Hi Madhouse,

Thank you for your detailed answer and trying to help me fix this problem, I really appreciate it. This project really is important for us as it’s our first professional installation using node-red and I admit that I am no expert at node-red programming, although I've been a professional coder for over twenty-five years.

I'll also say that this problem had me pulling my hair out.

I looked into all of your suggestions in detail, and you gave me some really constructive ideas.

You are correct, this is an industrial installation, but it is a pretty generic oven configuration so there’s no reason as to why I can’t share the hardware configuration as it is at the factory, where the PLC’s are Allen Bradley Micro 870’s and the HMI Touchscreens are also Allen Bradley Panelview 800’s.

Here's an image of the overall process, along with partial IP addresses.

All four ovens have the same flow and the same code in their respective Function nodes.

I solved this issue by doing two things.

Oven 1 used an Inject node to start the flow, but Ovens 2, 3 and 4 used a Complete node to execute their flows once the previous oven had completed its flow - changing the Complete nodes to Inject nodes on all four ovens with a one second off-set solved the problem of node-red pausing (or freezing, as I originally referred to it) when a PLC was turned off.

Also, to provide more information, when a network cable was removed the node-red flow paused, and yes, it did resume when the cable was plugged back in, but, when a PLC lost its power, as if in a real power outage, the flow didn't restart automatically.

That's working now because one oven isn't waiting on another oven to complete its flow through a Complete node. Lesson learned.

The second part of this solution was to include the following if statement in my code, under the Process node.

if (typeof msg.payload.buffer != 'undefined') {
    // Set the Payload Buffer

This prevented node-red from throwing an error and allowed me to set the buffer manually when it was undefined because of an unresolvable IP address.

I have some on-site testing to do tomorrow, but as I see it, at the moment, this issue is closed.

Thanks again for your contribution and your time.

Kind regards,

1 Like

Hi Colin!

Thanks for your reply.

When it is frozen can you communicate with the PLC from another modbus client?

Yes, I was able to communicate through other Modbus clients.

If, when it is frozen, you unplug the network cable for a while, then plug it back in, does it recover?

Yes, it recovers if I unplugged a network cable and plugged it back in after a period of time.

If you unplug the network cable, power cycle the PLC then plug the cable back in does it recover?

No, this is where the problem sat.

I was able to solve this issue today, it was two fold, the details are in my response to Madhouse's question.

Colin, once again, thank you very much for your time, this one had me pulling my hair out!

Kind regards,

Glad you were able to figure out your issue! Good luck on the project and hoping for lots of success!

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.