[zeromq-dev] zmq_msg_data problem

Chuck Remes cremes.devlist at mac.com
Tue Oct 18 00:55:21 CEST 2011


On Oct 17, 2011, at 5:19 PM, Mark Libucha wrote:

> Hi folks,
> 
> I'm using the latest stable zmq (v2.1.10) and Java bindings. My client is Java and server is C. This code in the server:
> 
>             printf("size=%d\n",zmq_msg_size(&zmq_request));
>             msgText = (const char *) zmq_msg_data(&zmq_request);
>             printf("size=%d\n",strlen(msgText));
> 
> prints this:
> 
> 2011-10-17 17:45:18,903 size=2808
> 2011-10-17 17:45:18,903 size=2809
> 
> The payload is JSON, but it's invalid when I run it through a parser.
> 
> Every so often the payload comes through correctly and the JSON gets parsed. (The JSON is a static string in the Java code -- not changing.)
> 
> Any hints as how to proceed?

0mq doesn't modify your data at all on send or recv.

To troubleshoot, I would modify the client.

1. On the client, try to parse the data you are sending. Pull it back out of the message structure and parse it. If it fails, then you are doing something wrong here.

That's the most likely source of your problem. Confirm the data that you are sending is good. If it *is good*, then use wireshark (or similar) to see the bytes on the wire. Grab those bytes and try to parse them.

cr




More information about the zeromq-dev mailing list