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
2
votes
1 answer

Using MsgPack custom serializer in C# application

I am experiencing difficulties with using MsgPack custom serializer in C#. Say, I have the following class: public class A { public int intA; public string strA; public B nestedB; } public class B { public string strB; public…
Yuri Girba
  • 31
  • 4
2
votes
1 answer

How to de-serialise the objects back after serialising them with pack_map or pack_array, in the c++ implementation of msgpack?

In the example given on http://wiki.msgpack.org/pages/viewpage.action?pageId=1081387#QuickStartforC%2B%2B-Streamingintoanarrayormap, how do I unpack the items from the array or map (when using pack_map and pack_array) in the c++ implementaton if…
oracal
  • 835
  • 1
  • 8
  • 13
2
votes
1 answer

MsgPack third-party objects serialization

I'm trying to serialize object with MsgPack (Java). This object (among other things) contains JodaTime's LocalDate for representing - well - date. MsgPack is not able to deserialize my message, coming from .NET client counterpart, because it is…
Miro Hudak
  • 2,155
  • 2
  • 21
  • 29
2
votes
0 answers

msgpack deserialize c++

When I parse from the buffer, I have to know,what the exact class type(myclass) of the buffer is. So I cant handle all the buffer parse in an uniform way. I have to distinguish every class type(can I?). My questions is "how can i handle all the…
sinopec
  • 851
  • 1
  • 9
  • 16
2
votes
1 answer

Sockjs-tornado and rpc

I'm trying to add a sockjs-tornado server to my site, and all worked fine until I decided to connect it to my other apps via MsgPack (using msgpack-rpc-python). And now works sockjs server either RPC server. Depending on wich of them start there…
Jerry92
  • 23
  • 2
2
votes
2 answers

can't decode encrypted string in python from messagepack (Ruby openssl)

I'm having trouble unencoding some data I get from a socket connection through messagepack, and consequentially unencrypting it. I get the string in from a Ruby on Rails web application in UTF-8 and use messagepack to bundle it all up and send it…
Hunter Barrington
  • 143
  • 1
  • 1
  • 11
1
vote
1 answer

C# application talking with ruby msgpack server which is expecting a ruby-type hash?

I am looking to build a small application to talk with a ruby msgpack server in C#. My only holdup so far is that the API behind the server is expecting to pull out a ruby hash. Can I use a simple dictionary/key-value pair type in C#? If not, what…
user319249
  • 145
  • 1
  • 8
1
vote
2 answers

C++ msgpack User-defined classes - can't get started

I've been looking at the C++ quick-start guide for msgpack. http://wiki.msgpack.org/pages/viewpage.action?pageId=1081387 There, there is the following code snippet: #include #include #include class myclass…
Eamorr
  • 9,872
  • 34
  • 125
  • 209
1
vote
1 answer

How to convert from JSONObject to MessagePack?

I want to know if there is a way, in Java, to convert a JSONObject or a String with JSONObject format to MessagePack. I tried to use MessagePackFactory but it doesn't seem to work. My JSONObject looks like…
Nicole
  • 11
  • 1
1
vote
0 answers

Automatically importing UnityEngine in generated MessagePack resolvers

I'm trying to start using MessagePack in my Unity project. I've followed the instructions to generate resolvers using mpc through the provided Unity editor plugin, since my project needs to be AOT. It works, but if my classes contain members of…
Saturn
  • 17,888
  • 49
  • 145
  • 271
1
vote
1 answer

Using MessagePack protocol in the context of serverless Azure SignalR services

The following code works fine with my Azure SignalR Services (serverless mode) and I am able to receieve messages/events successfully. var connection = new HubConnectionBuilder() .WithUrl(connectionInfo.NegotiationUrl!, options => …
Arash
  • 3,628
  • 5
  • 46
  • 70
1
vote
0 answers

load model spacy error: ExtraData: unpack(b) received extra data

I have trained a custom NER model in spacy(v3.4.2) and then I trained the Roberta base model for custom NER again with spacy(v3.4.4) transformers. Now I am trying to load the Roberta trained model in spacy(v3.4.2) in order to combine NERs and I am…
Mel
  • 45
  • 5
1
vote
1 answer

Deserialize MessagePack data in Python generated in .NET with struct

I have a program which serialises a large amount of data (450 data points) in .NET using MessagePack with a Struct. I can deserialise the data in Python but I can not obtain the key structure in Python. .NET byte[] statusBytes =…
Ben K
  • 37
  • 6
1
vote
1 answer

Value doesn't live enough, but can't understand the reason

Good day! I'm struggling with a rust program due to a lifetime problem which I can't understand why it happens...It's a tokio thread trying to pass some data to another one using a mpsc. The argument is a &[u8], it's a buffer fulfilled by converting…
Gabbo
  • 11
  • 2
1
vote
1 answer

knowing end of message in protocol with msgpack

How do you manage end of a message in a protocol ? I use msgpack-c and the only solution I found is to send the header before the payload (separately). Send the header to client : // header { "message_type": "hello", "payload_size": 10 } The…
Lukkyz
  • 44
  • 5