noodlefrenzy / node-amqp10

amqp10 is a promise-based, AMQP 1.0 compliant node.js client
MIT License
134 stars 56 forks source link

Client stops receiving messages after 100 messages. #82

Closed groeneveld closed 9 years ago

groeneveld commented 9 years ago

The connection is still open though. Restarting the program resets the "counter" to 0. I am using a very simple implementation.

client.connect("myserver", function(connError) {
    client.receive("mytopic", function(rxError, payload, annotation) {
        console.log('New message');
    });
});

I left out my error checking and message processing stuff. I found some "100" constants in the source code but am not sure of their meaning.

mbroadst commented 9 years ago

@groeneveld can you provide information on what broker you're using, or any specific connection options you are using? I've run benchmarks with this lib against rabbitmq (with the amqp1.0 plugin), as well as qpid with messages counts up to 1M and not run into this issue.

midramas commented 9 years ago

I guess it's the same problem I have with the "not acknowledged" messages. After restarting the program the broker (ActiveMQ) send the same 100 messages again, because they aren't acknowledged yet :)

groeneveld commented 9 years ago

This is my entire setup, minus the payload processing bits and credentials. I'm talking to the server admin and I'll get back with what he says.

client.connect("amqp://username:password@ip:port", function(connError) {
    if (connError) console.log("No connection" + connError.reason);
    else console.log("Connected");
    client.receive("topic://mytopic", newMessage);
});

var newMessage = Meteor.bindEnvironment(function(rxError, payload, annotation) {
    if (rxError) console.log("Error receiving message: " + rxError.reason);
    else console.log('New message');
});
mbroadst commented 9 years ago

@midramas it really depends on how your sending, as well as the configuration of the broker. IIRC node-amqp10 defaults to auto-settle, so you shouldn't be receiving those issues afaict. ActiveMQ follows some pretty strange proprietary rules however so we can't count on the same behavior in that case it seems :smile:

@groeneveld it looks like you're connecting to ActiveMQ or JBoss maybe? Getting info on what particular broker you're using is going to be pretty helpful here, as there are a few and they vary in small but meaningful ways

noodlefrenzy commented 9 years ago

ActiveMQ is not AMQP-1.0 compliant, as far as I can tell. It ignores "auto-settle", and I've modified a branch to send Disposition frames per message to explicitly settle them and it ignores those too. I'm still trying to figure out how exactly we're failing to communicate, but it's pretty clearly violating spec on this one.

midramas commented 9 years ago

@mbroadst If you are interested on this topic https://github.com/noodlefrenzy/node-amqp10/issues/50

groeneveld commented 9 years ago

This is from my broker's log. It looks like I have an ActiveMQ acknowledgement problem too.

WARN | TopicSubscription: destinations=1, dispatched=100, delivered=0, matched=101, discarded=0: has twice its prefetch limit pending, without an ack; it appears to be slow | org.apache.activemq.broker.region.TopicSubscription | ActiveMQ Transport: tcp:///ip:port@port

mbroadst commented 9 years ago

@groeneveld not sure if you're still using this or not, but you might give the master branch a whirl and see if solves your problem. We've implemented basic disposition support which I would guess was the root cause of your issue.

groeneveld commented 9 years ago

Thanks for the update. I've switched to Stomp though.