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

How to receive exception when Amqp fails to connect? #102

Open
javiertrancoso opened this issue Oct 31, 2019 · 2 comments
Open

How to receive exception when Amqp fails to connect? #102

javiertrancoso opened this issue Oct 31, 2019 · 2 comments

Comments

@javiertrancoso
Copy link

const amqp = require('amqp-connection-manager')

const {CONNECTION_URL} = require('./config/env')

class AmqpConnectionService {

  async openConnection() {
    this.connection = await amqp.connect([CONNECTION_URL])
    this.channelWrapper = await this.connection.createChannel({setup(channel) {}})

    await this.channelWrapper.waitForConnect()
  }

With this code when the CONNECTION_URL is a wrong URL then the code get stuck on the waitForConnect().

@tstelzer
Copy link

FYI, at least judging by the types provided, neither amqp.connect, nor connection.createChannel return Promises, so using await is incorrect.

@jwalton
Copy link
Owner

jwalton commented Mar 25, 2020

Whenever a connection fails, you'll get a disconnect event even amqp-connection-manager is not currently connected to RabbitMQ.

But, amqp-connection-manager doesn't know the difference between trying to connect to a bad URL, and connecting to a broker that is currently down - either way ampq-connection-manager has to just keep retrying and hope it eventually works.

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