# Protobuf encoder returns empty buffer payload (3)

**URL:** <https://discourse.nodered.org/t/protobuf-encoder-returns-empty-buffer-payload-3/75517>\
**Category:** General\
**Created:** [21 February 2023 16:15 UTC](https://discourse.nodered.org/t/protobuf-encoder-returns-empty-buffer-payload-3/75517 "2023-02-21T16:15:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JohnnyPicnic](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/johnnypicnic/32/34787_2.png) [@JohnnyPicnic](https://discourse.nodered.org/u/JohnnyPicnic)\
**Post date:** [21 February 2023 16:15 UTC](https://discourse.nodered.org/t/protobuf-encoder-returns-empty-buffer-payload-3/75517/1 "2023-02-21T16:15:55Z")

</div>

I see there are two other topics on this issue but I'm still having trouble getting my message to encode.  
As suggested by the first topic I tried nesting the payload inside another payload. Either way I still get an empty buffer.

 ![2023-02-21_9-14-19](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/e/6ee5d56cd1ed698a3b1c417703edaeddd72b8fd2.png)

```auto
[{"id":"42390cb95143b779","type":"encode","z":"d03c03b6d2f91f47","name":"Encode Config","protofile":"7c162e491502f623","protoType":"ProtoConfig","x":1060,"y":700,"wires":[["570252569051c5e8"]]},{"id":"77852e69f064eb7d","type":"inject","z":"d03c03b6d2f91f47","name":"","props":[{"p":"payload.request_device_info","v":"true","vt":"bool"},{"p":"payload.current_time","v":"","vt":"date"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":850,"y":700,"wires":[["42390cb95143b779","9697fbfc2a43d17d"]]},{"id":"570252569051c5e8","type":"debug","z":"d03c03b6d2f91f47","name":"debug 38","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1280,"y":700,"wires":[]},{"id":"9697fbfc2a43d17d","type":"debug","z":"d03c03b6d2f91f47","name":"debug 39","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1040,"y":760,"wires":[]},{"id":"7c162e491502f623","type":"protobuf-file","protopath":"/home/pi/Proto/proto_config.proto","watchFile":false,"keepCase":false}]

```

Proto file:  
[proto\_config.proto](https://github.com/efento/Proto-files/blob/main/proto_config.proto)

---

<div class="post-metadata">

**Author:** ![JohnnyPicnic](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/johnnypicnic/32/34787_2.png) [@JohnnyPicnic](https://discourse.nodered.org/u/JohnnyPicnic)\
**Post date:** [22 February 2023 18:02 UTC](https://discourse.nodered.org/t/protobuf-encoder-returns-empty-buffer-payload-3/75517/2 "2023-02-22T18:02:39Z")

</div>

Can anyone point me in the right direction?  
This is the proto file complied for python  
[proto\_config\_pb2.py](https://github.com/efento/Efento-NB-IoT-sensors-remote-configuration-examples/blob/main/protobuf/proto_config_pb2.py)  
And the python code I'm trying to replicate is:

```auto
    def setTimestamp(self):
        # Serializing device config.
        device_config = proto_config_pb2.ProtoConfig()
        # Set request_device_info to true
        device_config.request_device_info = True
        # Sending current time to the sensor in order to synchronise its internal clock
        device_config.current_time = self.time
        return device_config.SerializeToString()

```

---

<div class="post-metadata">

**Author:** ![JohnnyPicnic](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/johnnypicnic/32/34787_2.png) [@JohnnyPicnic](https://discourse.nodered.org/u/JohnnyPicnic)\
**Post date:** [22 February 2023 20:03 UTC](https://discourse.nodered.org/t/protobuf-encoder-returns-empty-buffer-payload-3/75517/3 "2023-02-22T20:03:50Z")

</div>

I think I got this working after enabling the "Keep snake\_case (underscores)" 🤨

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [8 March 2023 20:04 UTC](https://discourse.nodered.org/t/protobuf-encoder-returns-empty-buffer-payload-3/75517/4 "2023-03-08T20:04:08Z")

</div>

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