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

Sending data through ZeroMQ (zmqpp) using MsgPack gives 'msgpack::v1::insufficient_bytes' error

I made a PUB/SUB connection using zmqpp and now I want to send data from the publisher to the subscribers using the header-only, C++11 version of msgpack-c. The publisher has to send 2 int64_t numbers -- header_1 and header_2 -- followed by a…
maddouri
  • 3,737
  • 5
  • 29
  • 51
3
votes
2 answers

How to unpack a msgpack file?

I am writing msgpack-encoded data to a file. On writing, I am just using the fbuffer of the C API. As in (I striped all error handling for the example): FILE *fp = fopen(filename, "ab"); msgpack_packer pk; msgpack_packer_init(pk, fp,…
Alex
  • 871
  • 7
  • 23
3
votes
2 answers

Retrieving Msgpack from Http request in java

I am trying to retrieve a msgpack object sent by my rails server in an AsyncTask. Rails controller - Rails respond_to do |format| format.json { render json: data.to_json } format.msgpack { render msgpack: data.to_msgpack } end AsyncTask…
Jackyto
  • 1,569
  • 3
  • 15
  • 33
3
votes
1 answer

Unpacking msgpack to an arbitrary object, without msgpack_define

I'm working on a body of code which deals with a custom String implementation rather than the std::string (long story but for various reasons this has to be used) which I will refer to as "String" from here on. I was able to easily pack the String…
Zeroshade
  • 463
  • 2
  • 8
3
votes
1 answer

Sending a vector through zeromq with msgpack

I can't seem to send a vector of a struct that I serialized with msgpack through ZeroMQ. It's a vector of this struct: struct MyData { MyData() : id(0), x(0), y(0), a(0) {} MyData(const Obj &r) : id(0), x(r.pose[0]), y(r.pose[1]),…
noko
  • 1,129
  • 2
  • 14
  • 25
3
votes
1 answer

Deserialize a type containing a Dictionary property using ServiceStack JsonSerializer

The code snippet below shows two ways I could achieve this. The first is using MsgPack and the second test is using ServiceStack's JSONSerializer. The second is more favourable because the ServiceStack.Text JSONSerializer is used throughout a…
leon
  • 762
  • 1
  • 10
  • 24
3
votes
1 answer

using MsgPack with Servicestack: how do I do KnownType?

I'm attempting to support the MessagePack protocol in my current Servicestack implementation. I need it to support (de)serializing a list of ISegment defined like this: [KnownType(typeof(ArcSegment)), KnownType(typeof(LineSegment))] public class…
Brannon
  • 5,324
  • 4
  • 35
  • 83
3
votes
2 answers

MessagePack Serializing object error on Android

use messagepack on android, the can serialize/deserialize a class, but not absolutely right . the simple test class: @Message public class Account { public String Code; public int Sequence; public float Lot; public String…
3
votes
1 answer

MessagePack C API

In looking at the C API for MessagePack, there are a number of functions to appropriately serialize (pack) the data according to type: msgpack_pack_uint8, msgpack_pack_int32, ... There doesn't seem to be the equivalent call in the API to unpack the…
CNK
  • 1,053
  • 2
  • 11
  • 17
3
votes
2 answers

How to remove a compiler option that python disutils includes (language code=pic32 not recognized)

I'm trying to compile the msgpack-python python module with gcc (v4.7) on solaris 10. The python installed is 2.6.8. Distutils is automatically picking up a incorrect compiler option (-xcode=pic32) that I want to remove from command. The full…
user1522264
  • 123
  • 1
  • 1
  • 5
3
votes
0 answers

msgpack-python Unable to allocate internal buffer

I used msgpack-python 0.1.12 in a uwsgi server with python2.7.2 . After running for some time, the server will throw a lot of exceptions as follows: File "_msgpack.pyx", line 171, in msgpack._msgpack.packb (msgpack/_msgpack.c:2356) File…
2
votes
2 answers

How to invoke a MessagePack RPC service from Javascript?

I've got this simple Java server process running as a MessagePack RPC service. I want to invoke the hello() service from Javascript, not Java, but have yet to find an example on how to achieve it. There does not appear to be a RPC implementation for…
raffian
  • 31,267
  • 26
  • 103
  • 174
2
votes
1 answer

Sinatra binary return for msgpack -- charset issue/ characters being converted somewhere?

I'm currently trying to return msgpack http://msgpack.org/ from a ruby sinatra service and parse it using javascript. I am using the javascript library found here: https://github.com/uupaa/msgpack.js/ (though I don't think that's relevant to this…
Michael Wasser
  • 1,776
  • 2
  • 21
  • 32
2
votes
2 answers

How to deserialize SignalR messages from Redis backplane

I need to read published messages by SignalR from Redis backplane. But they have strange format for me.…
Szyszka947
  • 473
  • 2
  • 5
  • 21
2
votes
0 answers

Extract specific values from a string of real-time pupil labs data

I am working on an eye-tracking project and need to plot real-time gaze data from the pupil core system. I am currently reading in live values through a network API to python, and I get hundreds of data points every second. The data comes as a large…
achadd7
  • 21
  • 3