Skip to content
Latchkey

Pulsar "AuthenticationException" in CI

The broker has authentication enabled and rejected the client. The client either sent no credentials, sent a token signed by a key the broker does not trust, or used a token that has expired.

What this error means

The client fails with "org.apache.pulsar.client.api.PulsarClientException$AuthenticationException: Failed to authenticate" on connect.

Terminal
org.apache.pulsar.client.api.PulsarClientException$AuthenticationException:
Failed to authenticate

Common causes

No token on an authenticated broker

The broker requires a token but the client connected without an authentication plugin configured.

Token not trusted or expired

The token is signed by a key the broker does not have, or its expiry has passed, so authentication fails.

How to fix it

Provide a matching token to the client

Configure the JWT auth plugin with the token the broker was started to trust.

.github/workflows/ci.yml
env:
  PULSAR_AUTH_PLUGIN: org.apache.pulsar.client.impl.auth.AuthenticationToken
  PULSAR_AUTH_PARAMS: token:${{ secrets.PULSAR_TOKEN }}

Disable auth for an isolated test broker

If the test broker does not need auth, run standalone without authentication so the client connects cleanly.

  1. Start Pulsar standalone with authentication disabled for tests.
  2. Remove the auth plugin from the client config.
  3. Re-run so the connection no longer requires a token.

How to prevent it

  • Inject Pulsar tokens from CI secrets, never committed config.
  • Keep the broker trust key and client token in sync.
  • Use unauthenticated standalone for isolated test brokers.

Frequently asked questions

What causes "Pulsar "AuthenticationException""?
The broker requires a token but the client connected without an authentication plugin configured.
How do I fix Pulsar "AuthenticationException"?
Configure the JWT auth plugin with the token the broker was started to trust.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card