Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9135699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:51:29+00:00 2026-06-17T08:51:29+00:00

I was using zeroMQ in nodeJS. But it seems that while sending the data

  • 0

I was using zeroMQ in nodeJS. But it seems that while sending the data from producer to worker, if I do not put it in setInterval, then it does not send the data to the worker. My example code is as follows:

producer.js
===========           
     var zmq = require('zmq')
      , sock = zmq.socket('push');

    sock.bindSync('tcp://127.0.0.1:3000');
    console.log('Producer bound to port 3000');
    //sock.send("hello");
    var i = 0;

     //1. var timer = setInterval(function() {
      var str = "hello";
      console.log('sending work', str, i++);

     sock.send(str);
     //2. clearTimeout(timer);
     //3. }, 150);

    sock.on('message', function(msg) {
    console.log("Got A message, [%s], [%s]", msg);
   });

So in the above code, if I add back the lines commented in 1, 2 and 3, then I do receive the message to the worker side, else it does not work.

Can anyone throw light why to send message I need to put it in setInterval? Or am I doing something wrong way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:51:29+00:00Added an answer on June 17, 2026 at 8:51 am

    The problem is hidden in the zmq bindings for node.js . I’ve just spent some time digging into it and it basically does this on send():

    1. Enqueue the message
    2. Flush buffers

    Now the problem is in the flushing part, because it does

    1. Check if the output socket is ready, otherwise return
    2. Flush the enqueued messages

    In your code, because you call bind and immediately send, there is no worker connected at the moment of the call, because they simply didn’t have enough time to notice. So the message is enqueued and we are waiting for some workers to appear. Now the interesting part – where do we check for new workers? In the send function itself! So unless we call send() later, when there are actually some workers connected, our messages are never flushed and they are enqueued forever. And that is why setInterval works, because workers have enough time to notice and connect and you periodically check if there are any.

    You can find the interesting part at https://github.com/JustinTulloss/zeromq.node/blob/master/lib/index.js#L277 .

    Cheers 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Socket.IO to have a client webpage fetch data dynamically from my
I'm working on a project that uses both .net and java, using zeromq to
I am using the zeromq client server model. My client takes options from the
I alreay can implement chat daemons using gevent and zeromq, but I'd like to
I'm currently using json and http to call perl functions from python, but it's
I have played a while with ZeroMQ and have couple questions/problems that I came
I want to connect clients to a server using ZeroMQ (java bindings, jzmq), but
I have a working application using python and zeromq and I would like to
I have installed zeromq 2.1.11 on mac os x using the steps given on
using Telerik.WinControls.Data; using Telerik.WinControls.UI.Export; namespace Directory { public partial class radForm : Form {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.