question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pub/Sub stops after first message has been received.

See original GitHub issue

I am absolutely new to nanomsg, so I might be doing something really stupid, but I can’t get this simple PUBSUB example to work:

var nano = require('nanomsg');
var addr = 'tcp://127.0.0.1:7789'

var pub = nano.socket('pub');
pub.bind(addr);

var sub1 = nano.socket('sub');
sub1.on('data', function (buf) {
  console.log('sub1:' + String(buf));
});
sub1.chan(['topic1'])
sub1.connect(addr);

var sub2 = nano.socket('sub');
sub2.on('data', function (buf) {
  console.log('sub2:' + String(buf));
});
sub2.chan(['topic2'])
sub2.connect(addr);

setInterval(function () {
    console.log('sending');
    pub.send("topic1 Hello from nanomsg!");
    console.log('sent');
}, 1000);

Running this gives me:

sending
sent
sub1:topic1 Hello from nanomsg!

And then there is nothing more (even if the node process does not exit). I would expect the setInterval to do this repeatedly, but after the first message has been received there is nothing more.

Any ideas? I have tried this on nodejs 5.11.0 on my Mac and on 6.2.0 on an Ubuntu machine.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:30 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
reqsharkcommented, Jun 4, 2016

k thanks, yea i’m not a fan of this code: https://github.com/nickdesaulniers/node-nanomsg/blob/master/lib/index.js#L440

We need to fix this

0reactions
alimousazycommented, Jun 27, 2016

@reqshark Here is a pull request https://github.com/nickdesaulniers/node-nanomsg/pull/160, thanks for helping out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Google Pub/Sub Subscriber not receiving messages after a ...
Publishers just stop publishing messages and therefore there are no messages to receive. If you restart the subscriber and it starts receiving ......
Read more >
Pubsub stops receiving messages #5314 - GitHub
After a day or two of the subscriber running, it stops consuming the messages. I have to manually restart it to make it...
Read more >
Troubleshooting | Cloud Pub/Sub Documentation
Learn about troubleshooting steps that you might find helpful if you run into problems using Pub/Sub. Cannot create a subscription. Check that you...
Read more >
PubSub Pull Subscriber stops receiving messages randomly
I have a GKE cluster with three nodes, which are being subscribers to the same PubSub subscription. and polling continuously for new ...
Read more >
Ability to rate limit messages being sent from a topic to a ...
When Pub/Sub uses a push backoff, it stops delivering messages for 100 milliseconds to 60 seconds and then starts delivering messages again. ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found