How to pass the msg parameters through a node?

Hi I guess my question topic is slightly wrong. Anyways Ill explain here in detail.

I have a Node A wanting to pass msg.(anythin) to Node C. But my Node B ( Being a custom node built by a community member) does not pass the msg through the node. Currently I found a solution of using the context to store and retrieve it in the next node. But I face few circular reference issues (That is not quite problem here). I wanted to ask if there are any other ways on how to pass those messages via that custom node or any node if the custom node doesnt return the msg param?

Which custom node? If it is a well supported node then that should be fixed.

I would be hesitant to save the message in a context var, as you may run in to concurrency (race) issues.

If custom node B is not outputting any msg (e.g. email node), then why not send the message to both B and C? and if the order is important (i.e. first send to B and then to C) than you can use a function node with 2 outputs, to B and to C, and send the msg sequentially:

node.send([msg,null]);  // Send to B
return([null,msg]);  // Send to C

If B is sending some output, and you need this output together with your original msg, then call B, receive its output back to A and then call C.

I guess it depends on the specific situation you have, but you could use another wire to bypass node B.
Then join the messages from A and B before sending to C.

Personally I think all nodes should pass original message properties wherever possible, and my pet hate is that they should also allow properties and topics to be set in the config to negate the need for so many switch and change nodes :roll_eyes:

Perhaps this could be a black mark in the node scoring system to encourage authors to fix this :grinning:

1 Like

Unless there's an obvious reason it can't be fixed, you should raise an issue on GitHub.

An earlier discussion pointed out that not passing along the original message properties can make it impossible to use the node in a link call segment.

1 Like

Node-red-contrib-iiot-jwt Node.The github link is GitHub - BiancoRoyal/node-red-contrib-iiot-jwt: The JSON Web Token package for Node-RED.

I see that someone has already submitted an issue for this.

In the meantime it is safe to save and restore to flow context, provided that you can be sure that you will not pass in another message before the previous one has been fully actioned and the values restored to the message. Otherwise the second message will overwrite the context values before they have been picked up.

If you can't guarantee that then you can use this flow to make sure only one message at a time passes through the save - jwt node - restore nodes.

Replace the Some 'functions to be performed' and 'Some more stuff to do' nodes with your save - action - restore nodes.

[{"id":"b6630ded2db7d680","type":"inject","z":"bdd7be38.d3b55","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","_mcu":{"mcu":false},"x":120,"y":1700,"wires":[["ed63ee4225312b40"]]},{"id":"ed63ee4225312b40","type":"delay","z":"bdd7be38.d3b55","name":"Queue","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"_mcu":{"mcu":false},"x":290,"y":1700,"wires":[["d4d479e614e82a49","7eb760e019b512dc"]]},{"id":"a82c03c3d34f683c","type":"delay","z":"bdd7be38.d3b55","name":"Some more stuff to do","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"_mcu":{"mcu":false},"x":780,"y":1700,"wires":[["7c6253e5d34769ac","b23cea1074943d4d"]]},{"id":"2128a855234c1016","type":"link in","z":"bdd7be38.d3b55","name":"link in 1","links":["7c6253e5d34769ac"],"_mcu":{"mcu":false},"x":75,"y":1780,"wires":[["3a9faf0a95b4a9bb"]]},{"id":"7c6253e5d34769ac","type":"link out","z":"bdd7be38.d3b55","name":"link out 1","mode":"link","links":["2128a855234c1016"],"_mcu":{"mcu":false},"x":645,"y":1780,"wires":[]},{"id":"b23cea1074943d4d","type":"debug","z":"bdd7be38.d3b55","name":"OUT","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","_mcu":{"mcu":false},"x":650,"y":1620,"wires":[]},{"id":"d4d479e614e82a49","type":"debug","z":"bdd7be38.d3b55","name":"IN","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","_mcu":{"mcu":false},"x":450,"y":1620,"wires":[]},{"id":"3a9faf0a95b4a9bb","type":"function","z":"bdd7be38.d3b55","name":"Flush","func":"return {flush: 1}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"_mcu":{"mcu":false},"x":170,"y":1780,"wires":[["ed63ee4225312b40"]]},{"id":"7eb760e019b512dc","type":"function","z":"bdd7be38.d3b55","name":"Some functions to be performed","func":"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"_mcu":{"mcu":false},"x":530,"y":1700,"wires":[["a82c03c3d34f683c"]]},{"id":"e35f37deeae94860","type":"comment","z":"bdd7be38.d3b55","name":"Set the queue timeout to larger than you ever expect the process to take","info":"","_mcu":{"mcu":false},"x":250,"y":1580,"wires":[]}]

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