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

Heartbeat not honored? #95

Open
thundo opened this issue Oct 20, 2023 · 4 comments
Open

Heartbeat not honored? #95

thundo opened this issue Oct 20, 2023 · 4 comments

Comments

@thundo
Copy link

thundo commented Oct 20, 2023

Hi all!

I'm creating a channel with heartbeat enabled to a vanilla rabbitmq server. Connection/channel are good. Hearbeats are flowing (as you can see from the wireshark trace).

Later on, I physically disconnect the server machine's ethernet. My expectation is that after 2 heartbeats the connection will crash.

Instead, no heartbeats are exchanged anymore after that. The connection just hangs there indefinitely.

This is the code

import {AMQPClient} from '@cloudamqp/amqp-client';

const run = async () => {
    const amqp = new AMQPClient('amqp://test:test@mercurius?heartbeat=60');

    console.log(`Connecting to RabbitMQ ${amqp.host}:${amqp.port}, tls=${amqp.tls}, vhost=${amqp.vhost}, user=${amqp.username}...`);
    if (!amqp.heartbeat) {
        console.log('AMQPClient: heartbeat is disabled');
    } else {
        console.log(`AMQPClient: heartbeat set to ${amqp.heartbeat}`);
    }
    const conn = await amqp.connect();
    const channel = await conn.channel();
    console.log(`RabbitMQ channel ${channel.id} opened`);

    console.log(channel);
};

run();

Output

Connecting to RabbitMQ mercurius:5672, tls=false, vhost=/, user=test...
AMQPClient: heartbeat set to 60
RabbitMQ channel 1 opened
<ref *1> AMQPChannel {
  consumers: Map(0) {},
  rpcQueue: Promise { undefined },
  unconfirmedPublishes: [],
  closed: false,
  confirmId: 0,
  connection: AMQPClient {
    closed: false,
    channelMax: 2047,
    logger: Object [console] {
      log: [Function: log],
      warn: [Function: warn],
      dir: [Function: dir],
      time: [Function: time],
      timeEnd: [Function: timeEnd],
      timeLog: [Function: timeLog],
      trace: [Function: trace],
      assert: [Function: assert],
      clear: [Function: clear],
      count: [Function: count],
      countReset: [Function: countReset],
      group: [Function: group],
      groupEnd: [Function: groupEnd],
      table: [Function: table],
      debug: [Function: debug],
      info: [Function: info],
      dirxml: [Function: dirxml],
      error: [Function: error],
      groupCollapsed: [Function: groupCollapsed],
      Console: [Function: Console],
      profile: [Function: profile],
      profileEnd: [Function: profileEnd],
      timeStamp: [Function: timeStamp],
      context: [Function: context]
    },
    textEncoder: { encoding: 'utf-8' },
    bufferPool: [],
    vhost: '/',
    username: 'test',
    platform: 'node v18.15.0 win32 x64',
    channels: [ [AMQPChannel], [Circular *1] ],
    onerror: [Function (anonymous)],
    frameMax: 4096,
    heartbeat: 60,
    tls: false,
    tlsOptions: undefined,
    host: 'mercurius',
    port: 5672,
    insecure: false,
    framePos: 0,
    frameSize: 0
  },
  id: 1,
  onerror: [Function (anonymous)],
  resolveRPC: [Function (anonymous)],
  rejectRPC: [Function (anonymous)]
}

Wireshark trace
image

Am I under the wrong assumption that the connection should crash?
Thanks

@dentarg
Copy link
Member

dentarg commented Oct 20, 2023

Which version of amqp-client.js are you using?

@thundo
Copy link
Author

thundo commented Oct 20, 2023

Which version of amqp-client.js are you using?

Latest published, 3.1.1

@icastillejogomez
Copy link

I also have the same problem

@frankdejonge
Copy link

The same behaviour occurs when the credentials of a user are changed while they have active connections. No errors, just a stale connection and nothing is resolved anymore. This includes on publishing as well as consuming messages.

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

4 participants