Questions tagged [msgpack]

MessagePack is a binary-based efficient object serialization library. It enables to exchange structured objects between many languages like JSON. But unlike JSON, it is very fast and small.

MessagePack is a binary-based efficient object serialization library. It enables to exchange structured objects between many languages like JSON. But unlike JSON, it is very fast and small.

Typical small integer (like flags or error code) is saved only in 1 byte, and typical short string only needs 1 byte except the length of the string itself. [1,2,3] (3 elements array) is serialized in 4 bytes using MessagePack as follows:

> require 'msgpack'
> msg = [1,2,3].to_msgpack  #=> "\x93\x01\x02\x03"
> MessagePack.unpack(msg)   #=> [1,2,3]

Scalable RPC

MessagePack-RPC is cross-language RPC library for client, server and cluster applications. Because it releases you from complicated network programming completely and provides well-designed API, you can easily implement advanced network applications with MessagePack-RPC.

require 'msgpack/rpc'
class MyHandler
  def add(x,y) return x+y end
end
svr = MessagePack::RPC::Server.new
svr.listen('0.0.0.0', 18800, MyHandler.new)
svr.run

require 'msgpack/rpc'
c = MessagePack::RPC::Client.new('127.0.0.1',18800)
result = c.call(:add, 1, 2)  #=> 3

MessagePack is available for many languages:

  • C
  • C++
  • D
  • Erlang
  • Go
  • Haskell
  • Java
  • OCaml
  • Python
  • Perl
  • PHP
  • Ruby
  • Scala
409 questions
0
votes
0 answers

msgpack taking 20 seconds to deserialize 180mb of data

I'm new to rust & msgpack so thought i'd see if this is expected performance and if there's any significantly faster ways to use this crate. I have a file (it happens to be geolocation data from a maxmind csv database). It's approximately 180mb. I…
0
votes
1 answer

MessagePackObject not attribute class. Which is correct, the decompile shows it's not

I need to transfer tons of data, mainly Vector3s and wanted to give MsgPack a try. However after installing it, I can't set the proper attributes. When I try to set the [MessagePackObject] attribute, I get an error that MessagePackObject is not an…
Phyres
  • 45
  • 2
  • 9
0
votes
1 answer

MessagePack decode error when sended packet from C++ server to NodeJs server

I got problem when I tried sended some User-defined Class from C++ server to Nodejs Server By MessagePack . If I defined a variable to zero in my class then the decode will be broken. But If I defined a variable not equal zero then it will works…
0
votes
1 answer

How to serialize or deserialize a generic struct with messagepack?

I use rmp_serde to serialize and deserialize some structures. One structure contains a generic type, and the compiler says: error: the trait bound `T: api::_IMPL_SERIALIZE_FOR_User::_serde::Serialize` is not satisfied label: the trait…
Piotr Płaczek
  • 530
  • 1
  • 8
  • 20
0
votes
1 answer

Deserialize data from websocket response

I'm am trying to deserialize a WebSocket response with the package msgpacket. When trying to deserialize the packet response I am getting the error: Uncaught Error: Invalid argument: The byte array to deserialize is empty. Here is a basic snippet…
andrewjazbec
  • 859
  • 8
  • 20
0
votes
2 answers

How to determine length of the string while deserializing it from byte array?

I use MessagePackSerializer and try to deserialize byte array. But array can be very big (10-20 MBs). I am reading data into an intermediate buffer of 1000 bytes. And I read the data from them. But there is a problem: when I try to read a line too…
Admiral Land
  • 2,304
  • 7
  • 43
  • 81
0
votes
1 answer

How to convert msgpack to json format

I have used kafka to stream my messages which encoded using msgpack. After that, i used msgpack to decode the messages. But i cant find anyway to align or format the messages in order to make it more readable. consumer = KafkaConsumer( …
LI HO TAN
  • 113
  • 3
  • 11
0
votes
0 answers

What is MapHeader?

I can not understand what map is it. Should i write number of serialized elements in bytes array into it? var bytes = new byte[65356]; var s = MessagePackBinary.WriteMapHeader(ref bytes, 0, 567); var ss = MessagePackBinary.ReadMapHeader(bytes, 0,…
Admiral Land
  • 2,304
  • 7
  • 43
  • 81
0
votes
1 answer

Deserializing custom dictionary

I'm getting a HttpResponse and trying to deserialize it by doing this: response = (HttpWebResponse)request.GetResponse(); Stream objStream = response.GetResponseStream(); BinaryReader breader = new BinaryReader(objStream); byte[] buffer =…
user2146441
  • 220
  • 1
  • 19
  • 43
0
votes
1 answer

How to use Primitive API in MessagePack?

I try to serialize and deserealize like this: var mem = new MemoryStream(); MessagePackBinary.WriteInt64(mem, 1580358); var result = MessagePackBinary.ReadInt64(mem);` //System.InvalidOperationException: 'Invalid MessagePack code was detected,…
Admiral Land
  • 2,304
  • 7
  • 43
  • 81
0
votes
0 answers

Send MSGPack body generates HTTP 500

I actualy try to replicate a http request with a msgpack body request. I have the original request that works (several times testet, generates a http 200 statuscode) If i replicate the request for example in insomnia or in PowerShell or with curl i…
TimoC
  • 687
  • 2
  • 6
  • 15
0
votes
1 answer

Why C++ msgpack-c adds number 13 (0x0D) before number 10 (0x0A), but C# MessagePack-CSharp does not?

I was trying to use MessagePack to serialize integers from 0 to 127 in C++ and in C# on Windows, but the results are not the same. msgpack-c inserts 0x0D between 0x09 and 0x0A, but MessagePack-CSharp does not. Why is that? OS: Windows 10 IDE: Visual…
Jinjinov
  • 2,554
  • 4
  • 26
  • 45
0
votes
1 answer

How to enable Message Pack protocol in SignalR Azure Functions?

We have an Azure Function supporting a SignalR hub leveraging Azure SignalR Services to publish messages to connected signalR clients. We'd like to enable MessagePack protocol in the function but we could not find any documentation or guidelines to…
Arash
  • 3,628
  • 5
  • 46
  • 70
0
votes
1 answer

empty slice when parsing msgpack encoded slice of msgpack encoded individual slice

I am trying to decode a gzip response from server which an msgpack array or msgpack array which is finally gzipped. so to illustrate this my response looks something like: gzip(msgpack([msgpack([]), msgpack([]), msgpack([]) ....])) this is what I…
warl0ck
  • 3,356
  • 4
  • 27
  • 57
0
votes
1 answer

How to properly decode raw data response

I'm attempting to use an API (there is no documentation), the backend uses ScalaJS and uPickle (MsgPack) and it returns raw binary data for each API endpoint. I need to somehow covert this raw binary data to readable JSON. Here is my code: function…