Can't get req/res Info after onvif node call

Hi guys,

I am trying to resolve the request call that I make in node-red, and I am executing the onvif-discovery call to get information from the cameras, but when the node responds, the request information does not exist, and is required to respond to the request.
(I tried in different ways to pass the request information inside the msg, but apparently, it removes the msg info)
PS: I used the global context of node-red to save the request information, but I know that it is not the best option and it may be an anti-pattern

Node-RED version: v1.0.4

After execution --- outputs debug nodes

Selection_999(002)

What is the contrib node called (full name)? Where did you download it from / install it?

1 Like

Hey Steve,
It is about my node-red-contrib-onvif nodes, which have never arrived on npm due to a lack of time.

My discovery node creates a new output msg object, so the content of the original input msg is lost. Will need to change that...

2 Likes

The original msg is being over wrtten. You would need to pass the res around the onvif node, using a join node and a couple of change nodes ( this will work with other nodes that overwite msg to.)
here is an example

[{"id":"3a93dd69.8093ba","type":"http in","z":"c74669a0.6a34f8","name":"","url":"pass","method":"get","upload":false,"swaggerDoc":"","x":90,"y":2020,"wires":[["5a07664f.e35b7","216b5b20.8e14d4"]]},{"id":"5a07664f.e35b7","type":"change","z":"c74669a0.6a34f8","name":"onvif node simulation","rules":[{"t":"set","p":"payload","pt":"msg","to":"pass variable","tot":"str"},{"t":"delete","p":"req","pt":"msg"},{"t":"delete","p":"res","pt":"msg"},{"t":"set","p":"topic","pt":"msg","to":"onvif","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":2000,"wires":[["a80204cb.33efb"]]},{"id":"216b5b20.8e14d4","type":"change","z":"c74669a0.6a34f8","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"response","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":2040,"wires":[["a80204cb.33efb"]]},{"id":"a80204cb.33efb","type":"join","z":"c74669a0.6a34f8","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":510,"y":2020,"wires":[["340aa201.e4f69e"]]},{"id":"340aa201.e4f69e","type":"change","z":"c74669a0.6a34f8","name":"","rules":[{"t":"move","p":"payload.onvif","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":2120,"wires":[["9f1eb5d4.7c80a8","eb80991e.7c4d38"]]},{"id":"9f1eb5d4.7c80a8","type":"http response","z":"c74669a0.6a34f8","name":"","statusCode":"","headers":{},"x":570,"y":2120,"wires":[]},{"id":"eb80991e.7c4d38","type":"debug","z":"c74669a0.6a34f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":650,"y":2160,"wires":[]},{"id":"958281fe.d2101","type":"inject","z":"c74669a0.6a34f8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":220,"y":1880,"wires":[["2e3a91eb.958496"]]},{"id":"2e3a91eb.958496","type":"http request","z":"c74669a0.6a34f8","name":"test request","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://192.168.1.25:1880/pass","tls":"","persist":false,"proxy":"","authType":"","x":450,"y":1880,"wires":[["832b45bc.f25f88"]]},{"id":"832b45bc.f25f88","type":"debug","z":"c74669a0.6a34f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":610,"y":1880,"wires":[]}]
1 Like

@E1cid
Thanks for providing your workaround! But it was such a minor update to my code, that it was more work to put it on my todo list compared to adapting my code :wink:

@jamessantoya26: this should now be fixed when you install the onvif nodes again from my Github repository. Please let me know if it is solved!

Remark: when you specify to get a separate output for every device:

image

Then I will of course clone the input message for every output message. Otherwise people can get very strange behaviour which is hard to troubleshoot. But I'm not sure whether your input message (containing http request and response objects) will survive such a clone. You will need to test that.

1 Like

The workaround was also for other nodes that overwrite msg.

2 Likes

Guys, thanks for your quick responses, I really appreciate them..

@BartButenaers I'm going to install the onvif nodes again and I'll test that. thanks a lot! :+1: :clap:

1 Like

@BartButenaers Thank you very much, it worked, I have in my message the http request and response objects, I was struggling with that hehe

:clap: :clap:

1 Like

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