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

Duplicate on message handlers. #358

Open
tony-gutierrez opened this issue Feb 16, 2018 · 3 comments
Open

Duplicate on message handlers. #358

tony-gutierrez opened this issue Feb 16, 2018 · 3 comments

Comments

@tony-gutierrez
Copy link

I have to use logic in a 'connection:opened' handler to send a sas token.

If I do anything with the client in this 'connection:opened' event handler, I get two calls to my "on message" handler, regardless of where my receiver was created. I have verified I am only creating one receiver, once.

@karlvlam
Copy link

karlvlam commented Mar 9, 2018

I have the same issue.

@karlvlam
Copy link

karlvlam commented Mar 9, 2018

@tony-gutierrez I get the same issue. But when I pause for a while/ use nextTick in the event function, it do not raise duplicated message again.

Here's my workaround.

let client = null; 

function createReceivers() {
  // create receiver links
}

async function reconnectClient() {
    client = new AMQP.Client(policy);
    client.on('connection:opened', async function(){ 
        logger.info('[ListenConn]: opened');
        process.nextTick(createReceivers);       
    });

   try{
        await amqpConnListen.connect(config['MQ_CONNECT_STRING']);
    }catch(err){
      logger.error(err);
    }
}

karlvlam added a commit to karlvlam/node-amqp10 that referenced this issue Mar 12, 2018
@princjef
Copy link
Collaborator

princjef commented Apr 6, 2018

Have you tried listening to the connected event instead of connection:opened? That won't fire until your connection and session(s) have been initialized, at which point you should be able to do whatever you want with links, etc.

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