node-amqp10 icon indicating copy to clipboard operation
node-amqp10 copied to clipboard

Connect does nothing

Open Kmasterrr opened this issue 6 years ago • 2 comments

Hi there,

I am using Amazon MQ using the AMQP connection string and for some or other reason, the promises are not returning anything. No error or success..

I have copied the code from your examples, as well as played around with the policy and for some reason the application just waits..

Please assist. I just decommissioned my RabbitMQ server and now i need to sort the application via amazon MQ.

Code below:

var AMQPClient = require('amqp10').Client,
    Promise = require('bluebird'),
    Policy = require('amqp10').Policy;

var uri = 'my amazon amqp connection',
    msgId = Math.floor(Math.random() * 10000),
    client = new AMQPClient();

var client = new AMQPClient(Policy.merge({
    senderLinkPolicy: {
        callbackPolicy: Policy.Utils.SenderCallbackPolicies.OnSent
    }
}, Policy.DefaultPolicy));
client.connect(uri)
    .then(function() {
        return Promise.all([
            client.createReceiver('amq.topic'),
            client.createSender('amq.topic')
        ]);
    })
    .spread(function(receiver, sender) {
        receiver.on('errorReceived', function(err) { /* Check for errors */ });
        receiver.on('message', function(message) {
            console.log('Rx message: ', message.body);
        });

        return sender.send({ key: "Value" });
    })
    .error(function(err) {
        console.log("error: ", err);
    });

Kmasterrr avatar Jun 09 '18 00:06 Kmasterrr

I had this same issue. 1) if the connector is anonymous, you need to specify the SASL mechanism: https://stackoverflow.com/a/43913433/2084315

  1. if this is an authenticated user, I had to build the url with the creds in the url. (If there's a different way to do this, let me know.)

amqps://user:pw@url:5671

Be sure to run encodeURIComponent() your password before putting it in the url!

Also, if you have an AmazonMQ broker with failover, only one instance is available at a time. I've witnessed this switching back and forth unreliably as to which one is available. Try switching between your two urls (if you have them) if connect becomes unresponsive. I'm currently investigating whether this library supports setting up a failover.

ps2goat avatar Jun 15 '18 15:06 ps2goat

For those with the same issue under WildFly's embedded ActiveMQ message broker, see: https://issues.jboss.org/browse/WFLY-7823?focusedCommentId=13599179&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-13599179

jwgmeligmeyling avatar Jun 30 '18 12:06 jwgmeligmeyling