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

Proposal: reject connect() on authentication error #47

Open
intjohn opened this issue Apr 30, 2024 · 0 comments
Open

Proposal: reject connect() on authentication error #47

intjohn opened this issue Apr 30, 2024 · 0 comments

Comments

@intjohn
Copy link

intjohn commented Apr 30, 2024

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.

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

1 participant