msgpack-node icon indicating copy to clipboard operation
msgpack-node copied to clipboard

unpack buffer from python's msgpack API returned unexpected '-3'

Open ctlkkc opened this issue 5 years ago • 0 comments

Hi authors, I would like to seek for some assistance of the following issue:

I've got a python program to packb msgpack.packb into a kafka flow and was able to consume the flow. What I did with each message is to buffer.from the message and try to unpack on the node end - instead of getting the object I got '-3' as result.

Below I wrote some logic for troubleshooting:

 19     consumer.on('message', function (message) {
 20     const buf = Buffer.from(message["value"], 'binary');
 21     console.log("=========================================================================================================================")
 22     console.log('The buffer version of the message:')
 23     console.log(buf)
 24     console.log('The unpack version of the message:')
 25     console.log(msgpack.unpack(buf))
 26     console.log('The string version of the message:')
 27     console.log(message["value"])
 28     console.log('The binary version of the message:')
 29     console.log(buf.toString('hex').match(/../g).join(' '))
 30 });

And below is what the script returns:

=========================================================================================================================
The buffer version of the message:
<Buffer fd fd 49 6e 73 74 61 6e 63 65 fd 48 4b 4f 43 47 5f 50 fd 53 65 6e 74 54 69 6d 65 fd 32 30 31 39 30 32 30 31 2d 31 30 3a 35 30 3a 30 39 2e 38 31 34 34 ... >
The unpack version of the message:
-3
The string version of the message:
��Instance�HKOCG_P�SentTime�20190201-10:50:09.814407�Severity�W�AlertMessage��HKG OCG1 [Disconnected:0 R8802:8802:8555:0:0:0 L0 S6616:6616:6616:6363:6363:6363:0]: connect(10.1.93.17:50036): Connection refused�Acked�N
The binary version of the message:
fd fd 49 6e 73 74 61 6e 63 65 fd 48 4b 4f 43 47 5f 50 fd 53 65 6e 74 54 69 6d 65 fd 32 30 31 39 30 32 30 31 2d 31 30 3a 35 30 3a 30 39 2e 38 31 34 34 30 37 fd 53 65 76 65 72 69 74 79 fd 57 fd 41 6c 65 72 74 4d 65 73 73 61 67 65 fd 00 fd 48 4b 47 20 4f 43 47 31 20 5b 44 69 73 63 6f 6e 6e 65 63 74 65 64 3a 30 20 52 38 38 30 32 3a 38 38 30 32 3a 38 35 35 35 3a 30 3a 30 3a 30 20 4c 30 20 53 36 36 31 36 3a 36 36 31 36 3a 36 36 31 36 3a 36 33 36 33 3a 36 33 36 33 3a 36 33 36 33 3a 30 5d 3a 20 63 6f 6e 6e 65 63 74 28 31 30 2e 31 2e 39 33 2e 31 37 3a 35 30 30 33 36 29 3a 20 43 6f 6e 6e 65 63 74 69 6f 6e 20 72 65 66 75 73 65 64 fd 41 63 6b 65 64 fd 4e

What is wrong during the convert in the function? Thanks

ctlkkc avatar Feb 05 '19 03:02 ctlkkc