Skip to content

Heartbeat not honored? #95

@thundo

Description

@thundo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions