Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

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?

Problem

Scenario:

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

Information:

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

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

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

Issue:

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://127.0.0.1:2222

Node.js code:

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

C# code:

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

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

            try
            {
                // ZMQ Context and client socket
                using (var context = new Context(1))
                {
                    using (Socket client = context.Socket(SocketType.PUSH))
                    {
                        client.Connect("tcp://127.0.0.1:2222");

                        string request = "Hello";
                        for (int requestNum = 0; requestNum 

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

Problem courtesy of: Amol M Kulkarni

Solution

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

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

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

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×