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

  • SEARCH
  • Home
  • 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 6325085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:49:45+00:00 2026-05-24T16:49:45+00:00

I just started playing with node.js and the zeromq bindings today and am seeing

  • 0

I just started playing with node.js and the zeromq bindings today and am seeing some behavior that I don’t quite understand.

Here’s my sample code which calls to another ruby based zeromq REP process on port 9000 on the same machine:

var zeromq = require("zmq");
var http = require('http');

var counter = 0;

var availabilityResponse = function(counter, data, request, response) {
    var str = data.toString('utf-8');
    console.log(str);
    response.writeHead(200, {'Content-Type': 'text/plain'});
    response.write(str);
    response.end();                 
}

var zmqSocket = zeromq.createSocket('request');
zmqSocket.connect("tcp://127.0.0.1:9000");


var server = http.createServer()
server.on('request', function(request, response) {
    counter += 1;
    zmqSocket.send("Hola! - This is call # " + counter);
    zmqSocket.on('message', function(data) {
        availabilityResponse(counter, data, request, response);
    });

});
server.listen(8888);
console.log("Starting HTTP server on port 8888");

I’m hitting the node server using my browser and waiting for a response. What is strange is that the output I get in the console is coming across in an additive manner which I’m not grokking:

Request received: Hola! - This is call # 1 - Now going to sleep for 1.0

Request received: Hola! - This is call # 2 - Now going to sleep for 3.0
Request received: Hola! - This is call # 2 - Now going to sleep for 3.0

Request received: Hola! - This is call # 3 - Now going to sleep for 3.0
Request received: Hola! - This is call # 3 - Now going to sleep for 3.0
Request received: Hola! - This is call # 3 - Now going to sleep for 3.0

Request received: Hola! - This is call # 4 - Now going to sleep for 2.0
Request received: Hola! - This is call # 4 - Now going to sleep for 2.0
Request received: Hola! - This is call # 4 - Now going to sleep for 2.0
Request received: Hola! - This is call # 4 - Now going to sleep for 2.0

I tried moving the zmqSocket.on() call outside of the http request block which removes the additive behavior but it also doesn’t then include the request/response objects that I need.

The point of this exercise is to have the browser wait until the response comes back from the long running zeromq server process on port 9000 (currently just a faked up sleep response).

I’m pretty sure I’m just misunderstanding the callback here but can’t find much in the way of documentation on this scenario.

Thanks for any help.

  • 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-05-24T16:49:46+00:00Added an answer on May 24, 2026 at 4:49 pm

    You are rebinding your zmqSocket.on(‘message’, function(data) { event everytime an incoming request comes in. This is causing multiple event binds, move that block of code outside your request handler.

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

Sidebar

Related Questions

I just started playing around with threading today and I ran into something that
I just started playing around with the 960 CSS framework and found that it
I have just started playing with the ASP.Net MVC framework, and today I created
I just started playing with Django today and so far am finding it rather
I just started playing around with WPF today, and I couldn't find the datagridview
I just started playing in scala. I got a method that accepts string array
I've just started playing with Eclipse RCP. A few things that I would like
I've just started playing with GHCi. I see that list generators basically solve an
I've just started playing with Play! framework, and stumbled on such problem: modules that
I just started playing with nlog, and noticed that nlog.xml file is brought along

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.