How to debug Node-Red on IBM i

I’ve been asked for methods to debug nodes in Node-Red. Here is a brief introduction to this topic. This is very powerful and can save you time and energy when developing your flows.

  1. First we want to pull down the debug node and drop it into our flow. It will change to msg.payload once it is dropped in the flow.
  1. We can configure the debug node (msg.payload) settings or just leave it as the default. For this example we will just use the defaults.
    There are a number of settings that you can configure and tweak given what output you are trying to see. I would encourage you to try out the different options to see what they do.
  1. Let’s link the nodes we want to debug so we can see the output. I am going to link every node to the debug node just to show you what it does but you can select just the specific one(s) you would like to see.
  1. Now click Deploy to save the changes.
  2. Let’s click the debug icon on the right-hand side to see what output was produced by our node.

Our flow in this case has produced 4 different results.

  1. The SQL statement being passed to the database node
  2. The result of the returned SQL results
  3. The result after it has been prepared in the function node
  4. The result that will be displayed

In my case the last node in this flow has been configured to show 2 icons; a red danger sign if the result = 1 and a green check mark if the result = 0. If we check the dashboard we will see the green check mark.

This is what is looks like from the dashboard view:

NOTE: If you do not have your flow set to inject once, then x. You can click the box to the left of the node to execute it.

Now, let’s see what happens with our dashboard when it is not populating a node

I am completely missing the Subsystem table now (it may still be showing if your browser cached it).

Let’s add the debug node to figure out why.

We can see by the output in the Debug window that the SQL statement is not valid. It gives us the SQL error and the statement that it tried to execute. Can anyone see the mistake?

Turns out I spelled distinct wrong, making the SQL statement not valid.

I hope this has helped you. Well that ends my brief into to debugging in Node-Red. Feel free to post your comments and questions below.