Jacques44 / node-red-contrib-bigssh

remote command using ssh big node
Apache License 2.0
8 stars 12 forks source link

getting an error Converting circular structure to JSON when using http node which sets (msg.xxxxx) #27

Open sudoritz opened 3 years ago

sudoritz commented 3 years ago

Im not sure if the bigssh node supports being able to send other parent msg.{xxxx} and being able to pass them through the flow.

when i do a delete msg.req and msg.res it seems to work but

I then lose my http in/out ability.

a quick workaround i did was set msg.req / msg.res to flow.req flow.res and then when done i flip them back to the msg.res msg.req

Jacques44 commented 3 years ago

Hello,

do you have a test flow?

sudoritz commented 3 years ago

ahoy there :)

heres a test flow.

[{"id":"f635298b.343ff8","type":"tab","label":"deviceChk","disabled":false,"info":""},{"id":"a651860f.da0b08","type":"http in","z":"f635298b.343ff8","name":"","url":"/api/cmd","method":"get","upload":false,"swaggerDoc":"","x":90,"y":220,"wires":[["1089f6f2.969cc9","d97b23c7.ddcdd"]]},{"id":"d6c6070c.669378","type":"function","z":"f635298b.343ff8","name":"CMD","func":"msg.payload.cmd=\"ps -ef | grep \"+msg.payload.grep+\" \"\nreturn msg;","outputs":1,"noerr":0,"x":450,"y":220,"wires":[["66713a86.c02ee4"]]},{"id":"3b4608f7.1f60c8","type":"function","z":"f635298b.343ff8","name":"jsonParse","func":"msg.data=msg.payload.split('\n');\n\n\nmsg.payload ={\n \"Response\" : msg.data\n \n}\n\nreturn msg;","outputs":1,"noerr":0,"x":1040,"y":220,"wires":[["12e21e1b.f9fad2"]]},{"id":"12e21e1b.f9fad2","type":"http response","z":"f635298b.343ff8","name":"","statusCode":"200","headers":{},"x":1040,"y":280,"wires":[]},{"id":"66713a86.c02ee4","type":"bigssh","z":"f635298b.343ff8","name":"","commandLine":"${payload.cmd}","commandArgs":"","minError":1,"minWarning":1,"noStdin":false,"format":"utf8","payloadIsArg":true,"myssh":"1d63003e.fc33c","x":620,"y":220,"wires":[["961654c8.ad3c48","cedebe5b.6a29e"],[],[]]},{"id":"961654c8.ad3c48","type":"debug","z":"f635298b.343ff8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":830,"y":160,"wires":[]},{"id":"1089f6f2.969cc9","type":"debug","z":"f635298b.343ff8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":270,"y":180,"wires":[]},{"id":"d97b23c7.ddcdd","type":"change","z":"f635298b.343ff8","name":"","rules":[{"t":"move","p":"req","pt":"msg","to":"req","tot":"flow"},{"t":"move","p":"res","pt":"msg","to":"res","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":220,"wires":[["d6c6070c.669378"]]},{"id":"cedebe5b.6a29e","type":"change","z":"f635298b.343ff8","name":"","rules":[{"t":"move","p":"req","pt":"flow","to":"req","tot":"msg"},{"t":"move","p":"res","pt":"flow","to":"res","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":840,"y":200,"wires":[["3b4608f7.1f60c8"]]},{"id":"1d63003e.fc33c","type":"SSH_Credentials","z":"","host":"10.0.6.30","port":"22","userlabel":"root@10.0.6.30"}]

Jacques44 commented 3 years ago

Hello,

Do you have a biglib version up to date? I’ve made a change on Feb 18th in order to let messages flow though the big nodes

Regards

On 20 May 2021, at 15:25, sudoritz @.***> wrote:

ahoy there :)

heres a test flow.

[{"id":"f635298b.343ff8","type":"tab","label":"deviceChk","disabled":false,"info":""},{"id":"a651860f.da0b08","type":"http in","z":"f635298b.343ff8","name":"","url":"/api/cmd","method":"get","upload":false,"swaggerDoc":"","x":90,"y":220,"wires":[["1089f6f2.969cc9","d97b23c7.ddcdd"]]},{"id":"d6c6070c.669378","type":"function","z":"f635298b.343ff8","name":"CMD","func":"msg.payload.cmd="ps -ef | grep "+msg.payload.grep+" "\nreturn msg;","outputs":1,"noerr":0,"x":450,"y":220,"wires":[["66713a86.c02ee4"]]},{"id":"3b4608f7.1f60c8","type":"function","z":"f635298b.343ff8","name":"jsonParse","func":"msg.data=msg.payload.split('\n');\n\n\nmsg.payload ={\n "Response" : msg.data\n \n}\n\nreturn msg;","outputs":1,"noerr":0,"x":1040,"y":220,"wires":[["12e21e1b.f9fad2"]]},{"id":"12e21e1b.f9fad2","type":"http @.***"}]

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Jacques44/node-red-contrib-bigssh/issues/27#issuecomment-845119019, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEKS6M65YLFDDKDRDNY26NLTOUEWFANCNFSM45F4LSCA.

sudoritz commented 3 years ago

i did jump into my node-red docker instance to npm install node-red-biglib (i still seemed to have the issue)

Jacques44 commented 3 years ago

can you give me the version you are using?

onedr0p commented 3 years ago

Hi @Jacques44 I am having the same issue, here is my flow and I am using version 1.2.7

[{"id":"6293271e.851338","type":"http in","z":"9d3e0b06.9bb948","name":"[POST] Incoming Alert","url":"/power-outage","method":"post","upload":false,"swaggerDoc":"","x":200,"y":760,"wires":[["7007fca6.ad5534","209d63c5.f9fd3c","b018c175.c064c"]]},{"id":"7007fca6.ad5534","type":"change","z":"9d3e0b06.9bb948","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":700,"wires":[["1cef9d0c.787833"]]},{"id":"1cef9d0c.787833","type":"http response","z":"9d3e0b06.9bb948","name":"200","statusCode":"200","headers":{},"x":610,"y":700,"wires":[]},{"id":"209d63c5.f9fd3c","type":"debug","z":"9d3e0b06.9bb948","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":410,"y":760,"wires":[]},{"id":"b018c175.c064c","type":"change","z":"9d3e0b06.9bb948","name":"set alert payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.alerts[0]","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":820,"wires":[["56aa3a2a.2bc094","e85c17.be6f43e8"]]},{"id":"e85c17.be6f43e8","type":"switch","z":"9d3e0b06.9bb948","name":"power outage","property":"payload.labels.alertname","propertyType":"msg","rules":[{"t":"eq","v":"UPS15MinutesRemaining","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":660,"y":820,"wires":[["a4991cf.e4120e"]]},{"id":"a4991cf.e4120e","type":"switch","z":"9d3e0b06.9bb948","name":"status","property":"payload.status","propertyType":"msg","rules":[{"t":"eq","v":"resolved","vt":"str"},{"t":"eq","v":"firing","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":830,"y":820,"wires":[["b73ee85f.9beb38"],["419b55e1.0d5c8c"]]},{"id":"419b55e1.0d5c8c","type":"bigssh","z":"9d3e0b06.9bb948","name":"k8s-0","commandLine":"touch /tmp/test-off","commandArgs":"","minError":1,"minWarning":1,"noStdin":true,"format":"","payloadIsArg":false,"myssh":"7011fcd.62e3904","x":990,"y":880,"wires":[[],[],[]]},{"id":"b73ee85f.9beb38","type":"bigssh","z":"9d3e0b06.9bb948","name":"k8s-0","commandLine":"touch /tmp/test-on","commandArgs":"","minError":1,"minWarning":1,"noStdin":true,"format":"","payloadIsArg":false,"myssh":"7011fcd.62e3904","x":990,"y":760,"wires":[[],[],[]]},{"id":"56aa3a2a.2bc094","type":"debug","z":"9d3e0b06.9bb948","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":650,"y":880,"wires":[]},{"id":"7011fcd.62e3904","type":"SSH_Credentials","host":"192.168.42.10","port":"22","userlabel":"ubuntu@192.168.42.10"}]
Jacques44 commented 2 years ago

Hello,

I tested your flow. It was a bit difficult to find what does your POST send back..

I'm not able to get the error you've got. Sorry

onedr0p commented 2 years ago

No worries, I got it working by just setting res and req to empty before your plugin gets to them.