Help with runtime-API!

#1

Hello everyone,
I have embedded nodered. I’m working with the runtime-api.
I can launch the runtime and a flow.
The flow is: [inject-> function (n + n) -> debug] (mm, yes, this is why I do not work at NASA ;-))

I get to make inquiries through the API successfully. But I can not access the result of the function or the final payload of the flow.
I’ve tried things like this:
RED.nodes.getNode (‘id_node’). payload
RED.log.log (‘msg_id_from_editor’)

The node.log method redirects to the standard output of the main application correctly. But I’m looking for a way to bidirectional communication main_nodeapp <-> runtime-nred.

Thank you .

1 Like

#2

The runtime api (which is not formally documented etc etc) doesn’t provide any functions for interacting with flows. If you want to do so, you’d need to use nodes that you can interact with. For example, with the default palette, you could create a flow that listened on a TCP port and responded to it.

The better way would be to create a custom pair of nodes that expose themselves programmatically. We’ve had an item on the backlog to create such a set of nodes for a long time - https://trello.com/c/9pg4nqFX - just not got to it.

0 Likes

#3

Thank you,
good in this particular case I have disconnected the editor and the server. I just have running the flow inside my nodeapp. Everything is perfect and I get some kind of interaction through text files, clipboard, etc. But I need to share variables or be able to read from mynodeapp some flow value. I do not want to raise the server or use any port.

What you tell me makes me ask certain things:

  • From the runtime-api I can not read variables or messages?
  • Could I read fields or values of nodes from runtime-api ?
  • When you talk about creating a pair of nodes, would they be nodes that speak directly with node.js?
  • In the documentation, some functions receive the argument “msg”. What is this ? for example RED.log.log (msg) or RED.util.getMessageProperty (msg, expr)

Thank you and sorry for so many questions.

0 Likes

#4

The runtime API is not really supported at this level of detail. We’re working on a new api that will be properly supported in a future release

From the runtime-api I can not read variables or messages?

No

Could I read fields or values of nodes from runtime-api ?

The runtime API does let you access nodes - from there it depends on the individual nodes as to what they expose in a way you can access.

When you talk about creating a pair of nodes, would they be nodes that speak directly with node.js?

They would be nodes that you are able to access without having to go via the runtime api.

In the documentation, some functions receive the argument “msg”. What is this ? for example RED.log.log (msg) or RED.util.getMessageProperty (msg, expr)

To be clear, there is no formal documentation of the runtime API. I can’t stress this enough.

But, in general msg is a message object being passed through a flow.

1 Like

#5

Thanks, everything cleared.

1 Like

#6

Hi,

Can you please help me to embed NR nodes into existing Application?
we have requirement where we need NR nodes to be embed into our existing application, so it would be great help if you can help me on this.

Thanks in advance

0 Likes

#7

Adding a generic “help me” post to a very old post that has been marked resolved isn’t very useful.
Please open a new issue, with a specific issue after having read the relevant documentation on the website.

0 Likes

#8

Hi ukmoose,

Thanks for you input, actually I have raised an issue "Can any one help on embedding node-red in java process" 2 days back but did not get any response.
So i was going through all the topics and found this one is just related to my query.

If any one can help me to figure out whether it is possible or not that would be great help.

Thanks in advance

0 Likes

#9

Hi,
this is the official documentation to embed NR in another application Node.js
https://nodered.org/docs/embedding
I hope it helps you.

0 Likes

#10

Hello,
so as not to duplicate, we can continue the other conversation and close this one.
regards

0 Likes