assert in zmq::xrep_t::xrecv, zmq_assert (it != outpipes.end ());

Description

I changed my C code exactly as said in Upgrading from libzmq 2.1 to 3.1, http://www.zeromq.org/docs:3-0-upgrade.

My code works with 2.1.8 and 2.1.11 but it does not work with zeromq-3.1.0-beta (from web page). I tried tcp and inproc.

I tested in OSX 10.7. Version 2.1 does send data after zmq_sendmsg and zmq_msg_close. New version does not send any data. I tested this with CocoaPacketAnalyzer. Both version connect but after connect nothing is sent.

In windows XP and VisualStudio2010 my code crashes in zmq::xrep_t::xrecv method in line zmq_assert (it != outpipes.end ());.

My test code is almost exacty same as this rtrouter.c example. This rtrouter.c does not work either in 3.10 beta.

// rtrouter.c
// Cross-connected ROUTER sockets addressing each other
//
#include "zhelpers.h"

int main (void)
{
void *context = zmq_init (1);

void *worker = zmq_socket (context, ZMQ_ROUTER);
zmq_setsockopt (worker, ZMQ_IDENTITY, "WORKER", 6);
zmq_bind (worker, "ipc://rtrouter.ipc");

void *server = zmq_socket (context, ZMQ_ROUTER);
zmq_setsockopt (server, ZMQ_IDENTITY, "SERVER", 6);
zmq_connect (server, "ipc://rtrouter.ipc");

// Wait for the worker to connect so that when we send a message
// with routing envelope, it will actually match the worker...
sleep (1);

s_sendmore (server, "WORKER");
s_sendmore (server, "");
s_send (server, "send to worker");
s_dump (worker);

s_sendmore (worker, "SERVER");
s_sendmore (worker, "");
s_send (worker, "send to server");
s_dump (server);

zmq_close (worker);
zmq_close (server);
zmq_term (context);
return 0;
}

Environment

Chash in Windows XP and VisualStudio2010 using vc90. Does not send data in OSX.

Activity

Show:

pate stuta April 10, 2012 at 11:21 AM

Works in many tests in OSX and Windoows.

Martin Hurton April 10, 2012 at 7:21 AM

inproc reported to work on Windows and OSX.
Could we resolve and close this?

pate stuta April 4, 2012 at 10:16 PM

Sorry to inform you that this fix worked only for tcp.

this works: err = zmq_bind (server, "tcp://127.0.0.1:5555");

this does not work in osx/windows:
err = zmq_bind (server, "inproc://my-endpoint");

this does not work in osx (ipc is not supported in windows):
err = zmq_bind (server, "ipc://my-endpoint");

PieterP April 2, 2012 at 9:56 PM

Fixed in https://github.com/zeromq/libzmq/pull/301; Pasi if you could verify the fix that would be great.

Martin Hurton March 30, 2012 at 5:20 AM

The current implementation of router socket does not allow to send a message to a peer without first receiving some message from this peer. This is way why the above example fails. It's not enough that the peer connected, the app must receive some message first.
What is the correct behavior of router than?

Fixed

Details

Assignee

Reporter

Components

Affects versions

Priority

Created December 27, 2011 at 11:52 AM
Updated April 10, 2012 at 11:21 AM
Resolved April 10, 2012 at 11:21 AM