Protobuf encoder returns empty buffer payload

I am using node-red-contrib-protobuf

I got the decoder to work with my .proto just fine, but when I try to do it the other way around with the encoder it doesn't work and just returns to me a payload with buffer[0]. I expect it to return to me the serialized data (bytes) in a buffer array which is what I decoded successfully. I wonder if I might be missing something about the format of the message that is sent to the encoder node. Don't I just send:

msg.payload = {protobuf object as json}
return msg;

What could I be missing here? I am using the same messageType, if it works with the decoder, what could I be doing wrong with the encoder?

Thanks for your help in advance! And special thanks to the developer(s) of the node, extremely helpful!

Here are my nodes if you like to import and check:

[{"id":"8391aaeb.5c6448","type":"inject","z":"7a6c6b37.ffb0a4","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":610,"wires":[["c09f489e.5c6b28"]],"l":false},{"id":"f5d777ab.8e5228","type":"debug","z":"7a6c6b37.ffb0a4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":360,"y":610,"wires":[],"l":false},{"id":"c09f489e.5c6b28","type":"function","z":"7a6c6b37.ffb0a4","name":"","func":"msg.payload = {\n    \"correlationId\": 123,\n    \"getRequest\": {\n        \"objectId\": 10\n    }\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":220,"y":610,"wires":[["e03e784.769e088"]],"l":false},{"id":"e03e784.769e088","type":"encode","z":"7a6c6b37.ffb0a4","name":"","protofile":"44bcb8c1.0c0a58","protoType":"Message","x":290,"y":610,"wires":[["f5d777ab.8e5228"]],"l":false},{"id":"44bcb8c1.0c0a58","type":"protobuf-file","z":"","protopath":"/home/myProto.proto","watchFile":true}]

Just following up, hope anyone who has experience with protobuf node can help.


I got it working. The issue was in my proto format, I needed to have the payload nested under another payload. Like in:

msg.payload = { payload: { ....... } }
1 Like

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