I had wrote a node/ssjs program that makes:

  • Tcp connection to data server(Apache MIMA), using TLS module. (OK)
  • Encode/decode(serialize/deserialize) messages through protobuffer module.. (OK)
  • Send serialized message to server and get response. (Not OK).

The server´s manual types:

Structure of message:
[ Length | Header length | Header (| Body length |Body) ]
Length – message length = fixed size (4 bytes). Note that this is only the size of
         following message (not the prefix itself);
Header  length – fixed size (4 bytes);
Header – contains message metadata (e.g. messageId);
Body length – fixed size (4 bytes, optional). If body is not required, body size is 
              not serialized. In such case, message is 4 (message length) + 4 
              (header length) + length(header) bytes long.
Body – the message payload (optional). If body is not present (e.g. response
       notification without data) it is not serialized.

Length [bytes]  Content    
4               Whole message length       
4               Header message length (H_LEN)      
H_LEN           Protocol Buffers encoded MessageHeaderProto    
4               Body message length (B_LEN), optional      
B_LEN           Protocol Buffers encoded Message

My questions are:

  • How to get the 4-bytes-length of a protobuffer?
  • How to concatenate
    those buffers before send?
  • How to send?
  • Is it possible to do with
    JavaScript? Observation: The server uses Little Endian byte order,
    client side too.

Thank you all…