Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect does nothing #369

Open
Kmasterrr opened this issue Jun 9, 2018 · 2 comments
Open

Connect does nothing #369

Kmasterrr opened this issue Jun 9, 2018 · 2 comments

Comments

@Kmasterrr
Copy link

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);
    });
@ps2goat
Copy link

ps2goat commented Jun 15, 2018

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.

@jwgmeligmeyling
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants