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

zombie connections(flow connections) never closed #113

Closed
BlueHotDog opened this issue Jan 3, 2016 · 1 comment
Closed

zombie connections(flow connections) never closed #113

BlueHotDog opened this issue Jan 3, 2016 · 1 comment
Assignees

Comments

@BlueHotDog
Copy link

Hi, i've the following code:

const _ = require('lodash');
const config = ...
const rabbit = require('wascally');
const debug = require('debug')('wascally-helpers');

function exitOnConnectionClosed() {
  debug("connection closed");
  throw new Error("connection closed");
}

function exitOnConnectionFailed() {
  debug("connection failed");
  throw new Error("connection failed");
}

function setupRabbit(isExitOnClosed, isExitOnFailed) {
  if (_.isUndefined(isExitOnClosed)) {
    isExitOnClosed = true;
  }
  if (_.isUndefined(isExitOnFailed)) {
    isExitOnFailed = true;
  }
  if (isExitOnClosed) {
    rabbit.on('*.connection.closed', exitOnConnectionClosed);
  }

  if (isExitOnFailed) {
    rabbit.on("*.connection.failed", exitOnConnectionFailed);
  }

  return rabbit
    .configure(config)
    .then(function () {
      rabbit.nackOnError();
      rabbit.nackUnhandled();
      return rabbit;
    });
}

module.exports = _.once(setupRabbit);

the reason behind the auto-exit, is as a best practice from node, on-error, exit and retry, this proved to be the most stable solution for a worker use-case

the problem with that, is that we're now seeing a lot of "flow" connections in rabbit, and also zombie consumers.

tried a lot of things :(

nothing helps

@arobson
Copy link
Collaborator

arobson commented Jan 4, 2016

@BlueHotDog if you want the process to exit on connection failure, why not call process.exit with a non-zero code? I don't think throwing an exception from a callback will cause the process to exit.

I'm not sure what you mean by "flow" connections. Wascally will only establish a single connection. If the connection is lost, it will continuously attempt to try and re-establish the connection, your topology and subscriptions. If you don't want that behavior, you need to manually close the connection with the close method.

This seems related to your recent comments on issue #107 - I'm not sure how a zombie consumer is possible as Rabbit kills all consumers and channels when a connection is dropped. If you mean you're seeing consumers because wascally is re-connecting and re-subscribing, that's intended behavior. Call close on the connection or exit the process if you don't want that behavior.

@arobson arobson self-assigned this Jan 4, 2016
@arobson arobson closed this as completed Jun 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants