Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ZMQ via C# - clrzmq binding Windows XP fails but is OK on Win7

Tags:

c#

zeromq

I have been been developing a platform using ZMQ (2.2) as the main communications layer. Earlier this week I decided to take the advice on the zeromq website and upgrade to the latest stable build 3.2.2

However after going through the pain of updating to the new API I was seriously disappointed to discover that there seems to be a problem with the clrzmq binding in that it fails to load the libzmq library on Windows XP (SP3) machines. I keep getting a SEHException exception?!

I was just wondering if anyone out there has had the same problem and if there is a workaround (or even better a fix) for it?

Cheers :)

EDIT Just to clarify, the library is loaded fine, I know this because the context is created without any issue. The problem occurs when the CreateSocket method is called on the context... see code snippet below

        ZmqContext context = ZmqContext.Create();

        ZmqSocket socket = context.CreateSocket(SocketType.REQ);

After adding tracing as suggested by Jakob, I get the following output

Assertion failed: Connection refused (..\..\..\src\signaler.cpp:310)

Any Ideas what this means?

EDIT I should also mention that this issue does not happen on all the XP machines, only some of them. I have been trying to figure out what the difference is between the machines that work and the ones that don't. Without knowing this it would be far too risky to upgrade and release into a production environment.

like image 587
user1460473 Avatar asked Nov 13 '22 12:11

user1460473


1 Answers

Looking at the example you provided, you are binding to a REQ socket (Request, i.e. client socket), and also binding the REQ socket using wildcards. I am not sure how this will play out, but to me it does not make sense. I do not think this is supported but I cannot find or remember any documentation about binding to a REQ socket. Likely strange things will happen.

The REP (response) socket is the "server" end of a REQ/REP setup (request/response), where you bind the server side using a REP socket to an endpoint, either explicitly specified "tcp://127.0.0.1:5555" or using wildcards, e.g. "all interfaces", "tcp://*:5555". The client side would then connect using a REQ socket to an explicit endpoint address, "tcp://127.0.0.1:5555", no wildcards.

The server would do this:

ZmqContext context = ZmqContext.Create();
ZmqSocket socket = context.CreateSocket(SocketType.REP);
socket.Bind("tcp://*:5501");

And the client this:

ZmqContext context = ZmqContext.Create();
ZmqSocket socket = context.CreateSocket(SocketType.REQ);
socket.Connect("tcp://127.0.0.1:5501");

Apart from those issues, you should also make sure the firewall is not blocking and make sure the port is not already in use (using for example the NETSTAT command).

For ZeroMq addressing rules, see the zmq_tcp API documentation, and for the socket, see the zmq_socket API documentation.

like image 145
Jakob Möllås Avatar answered Nov 15 '22 06:11

Jakob Möllås