I would like to send a JSON package that gets “msgpack” and then compressed down using “zlib” down a post message to a server.
I tried to find examples online (here in the forum and on the internet) and could not find one.
I appreciate any advice on how to get a simple example running!
Thanks.
[{"id":"1ffa7fc1.97d7f","type":"msgpack","z":"b0e8c135.b7fa5","name":"","x":640,"y":360,"wires":[["8c50397.47b5dc8","d36df86c.c3f438"]]},{"id":"dc1720e6.2f7c1","type":"debug","z":"b0e8c135.b7fa5","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":850,"y":320,"wires":[]},{"id":"8c50397.47b5dc8","type":"function","z":"b0e8c135.b7fa5","name":"zlib (?)","func":"//https://stackoverflow.com/questions/33488690/node-red-access-to-zlib\n\ncontext.global.zlib.gunzip(msg.payload, function(err, buffer){\n \n if (!err)\n \n { \n console.log(\"*** ZLIB WORKING ***\")\n node.send( { payload: buffer.toString() });\n }\n\n else { console.log(\"***ERROR HANDLER ZLIB***\") } }); \n \nreturn msg;","outputs":1,"noerr":0,"x":830,"y":360,"wires":[["dc1720e6.2f7c1","7fc0db56.a563b4"]]},{"id":"7fc0db56.a563b4","type":"http request","z":"b0e8c135.b7fa5","name":"SAMPLES","method":"POST","ret":"obj","paytoqs":false,"url":"localhost:1881","tls":"","proxy":"","x":1050,"y":360,"wires":[["930b0948.4e45e8"]]},{"id":"ff9018c0.4b46e8","type":"inject","z":"b0e8c135.b7fa5","name":"","topic":"","payload":"{\"who\":\"me\",\"what\":\"help\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":490,"y":360,"wires":[["1ffa7fc1.97d7f"]]},{"id":"930b0948.4e45e8","type":"debug","z":"b0e8c135.b7fa5","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1050,"y":320,"wires":[]},{"id":"d36df86c.c3f438","type":"debug","z":"b0e8c135.b7fa5","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":650,"y":320,"wires":[]}]
Update:
- I added some "code" that I believe works, but would really like a second/third set of eyes to make sure I am doing the correct thing here!
- To test I create a simple TCP server to catch the response by: :~$ nc -l -p 1881
Thanks!