1

i'm trying to encode protobuf object (prepared by scalapb) and pass it to another service written in python (I think, it's doesn't matter, but I'm using NATS.io as messaging system).

val protoMsg: ProtoMessage = ProtoMessage(foo = "21266894", bar = 155)
conn.publish("my.topic", protoMsg.toByteArray)

Python protobuf deserializer can't deserialize this message, I think, that's expecting something like a hex string \xc0\xa9\xb6\xe3, but it receives something like [B@7d958728 instead.

What i'm doing wrong? How I can get a necessary representation of a bytearray?

  • It looks like on the receive side, you are not getting the content of the byte array, but the value of `protoMsg.toByteArray.toString` (see https://stackoverflow.com/questions/7060016/why-does-the-tostring-method-in-java-not-seem-to-work-for-an-array). The next step would be to figure out how to send an arbitrary array of bytes across, and getting the same byte array on the other side (regardless of ScalaPB). – thesamet Jan 31 '19 at 18:05
  • 1
    Does `protoMsg.toByteArray.mkString` work? – Brian McCutchon Feb 01 '19 at 06:47

0 Answers0