How to Push data from C# to ZeroMQ and Pull from Node.JS or vice-versa?

How to Push data from C# to ZeroMQ and Pull from Node.JS or vice-versa?



I am trying to send a data (say String type) from C# сonsole application to Node.JS server through ZeroMQ.


Using clrzmq for c# and ZeroMQ libs for C# and Node.JS respectively

I am able to perform push-pull from Node.JS, also pushpull from C#.

So, one thing is confirmed that ZeroMQ – The Intelligent Transport Layer is installed on the machine (Windows 7 64-bit)


I am not able to push data from C# Console app to Node.JS app (even tried vice-versa), both are on the same machine and on the same address i.e tcp://

Node.js code:

var zmq = require('zeromq.node');
var pull_socket = zmq.socket('pull');    
pull_socket.on('message', function (data) {
    console.log('received data:\n');

C# code:

namespace DataServiceEngine
    class Program
        static void Main(string[] args)
            //clsApp App = new clsApp();
            //App.appId = "001";
            // = "Back Office";

            //Console.WriteLine("appId :" + App.appId + "\n");
            //Console.WriteLine("name:" + + "\n");

                // ZMQ Context and client socket
                using (var context = new Context(1))
                    using (Socket client = context.Socket(SocketType.PUSH))

                        string request = "Hello";
                        for (int requestNum = 0; requestNum < 10; requestNum++)
                            Console.WriteLine("Sending request {0}...", requestNum);
                            client.Send(request, Encoding.Unicode);

                            string reply = client.Recv(Encoding.Unicode);
                            Console.WriteLine("Received reply {0}: {1}", requestNum, reply);
            catch (ZMQ.Exception exp)

Question: Can anyone tell me what may be the reason or where am I doing wrong?

Problem courtesy of: Amol M Kulkarni


I had the same issue (but I issued a communication Node.JS -> Node.JS). To solve the problem I used to do sendersocket.connect("tcp://"+host+":"+port); at the sender and receiversocket.bindSync("tcp://*:"+port); at the receiver.

Hope this fix your problem.

Solution courtesy of: Masiar


Leave a Reply

Your email address will not be published. Required fields are marked *