Skip to content

Proposal: reject connect() on authentication error #47

@intjohn

Description

@intjohn

Hi, I have a use case where authentication is required:

  const logger = new FluentClient("output", {
    socket: {
      host: "fluentd.local",
      port: 24224,
      timeout: 3000,
      disableReconnect: true,
      tls: {
        ca: require('fs').readFileSync('./fluentd.crt'),
      },
    },
    security: {
      clientHostname: "client.local",
      sharedKey: "incorrect",
      username: "ooo",
      password: "xxx"
    },
  });

  try {
    await logger.connect();
  } catch (err) {
    /* do something with err */
  }

When security is not correctly configured, connect() still resolves.

Though the error could be detected by logger.socketOn('error'), it's not synchronous with connect() and some mechanism to wait for the error (or to ensure no error thrown) is required.

If connect() can reject on error, it would be more easy to determine whether the client is authenticated successfully.

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