Skip to content

[Bug] [Pulsar-Client] Client says disconnected but producer and consumer can still produce/consume messages #25062

Closed

Description

@shasank112001

Search before reporting

  • I searched in the issues and found nothing similar.

Read release policy

  • I understand that unsupported versions don't get bug fixes. I will attempt to reproduce the issue on a supported version of Pulsar client and Pulsar broker.

User environment

Broker Version 4.1.0
Broker Java Version 17
Client Library Type: Java
Client Library Version: 4.1.0
Client Java Version: 17

Issue Description

I have the following cluster setup running locally:

  1. Pulsar Proxy:
    1. AuthenticationProviders: AuthenticationKeyStoreTLS, and JWT Authentication.
    2. AuthenticationEnabled: true
    3. BrokerClientParams: AuthenticationKeyStoreTLS
    4. forwardAuthorizationCredentials: true
    5. authenticationRefreshCheckSeconds: 5 seconds
  2. Pulsar Broker:
    1. AuthenticationProviders: AuthenticationKeyStoreTLS
    2. AuthenticationEnabled: true
    3. BrokerClientParams: AuthenticationKeyStoreTLS
    5. authenticateOriginalAuthData: false
  3. Pulsar Client:
    1. Authentication class: JWT

Test case:

  1. Client connects with a JWT token expiring in the next minute
  2. Client produces messages at 1 msg/sec

Expected Result:

  1. Client should produce for the first minute, and then stop with a PulsarClientException when Proxy reauthenticates the token

Observation:

  1. Proxy runs r-authentication, prints that the token has expired. Prints disconnect message
  2. Client prints the following messages:
[pulsar-client-io-18-3] WARN org.apache.pulsar.client.impl.ClientCnx - [id: 0x9ed69246, L:/127.0.0.1:62086 - R:localhost/127.0.0.1:62066] Received error from server: Failed to authenticate
[pulsar-client-io-18-3] ERROR org.apache.pulsar.client.impl.ClientCnx - [id: 0x9ed69246, L:/127.0.0.1:62086 - R:localhost/127.0.0.1:62066] Failed to authenticate the client
[pulsar-client-io-18-3] WARN org.apache.pulsar.client.impl.ClientCnx - [id: 0x9ed69246, L:/127.0.0.1:62086 - R:localhost/127.0.0.1:62066] Received unknown request id from server: -1
[pulsar-client-io-18-3] INFO org.apache.pulsar.client.impl.ClientCnx - [id: 0x9ed69246, L:/127.0.0.1:62086 ! R:localhost/127.0.0.1:62066] Disconnected
[pulsar-timer-62-1] INFO org.apache.pulsar.client.impl.ProducerStatsRecorderImpl - [persistent://security-test/security-namespace/security] [test-container-1-0-1] --- Publish throughput: 1.00 msg/s --- 0.00 Mbit/s --- Latency: med: 6.000 ms - 95pct: 20.000 ms - 99pct: 25.000 ms - 99.9pct: 25.000 ms - max: 25.000 ms --- BatchSize: med: 1.000 - 95pct: 1.000 - 99pct: 1.000 - 99.9pct: 1.000 - max: 1.000 --- MsgSize: med: 36.000 bytes - 95pct: 36.000 bytes - 99pct: 36.000 bytes - 99.9pct: 36.000 bytes - max: 36.000 bytes --- Ack received rate: 1.00 ack/s --- Failed messages: 0 --- Pending messages: 0

However, the producer.send and consumer message listener are still able to send and receive messages:

Produced message with ID 2:60:-1
[pulsar-external-listener-33-1] INFO xxxx - Received message with 2:60:-1
[main] INFO xxxx  - Produced message with ID 2:61:-1
[main] INFO xxxxx - Produced message with ID 2:62:-1
[pulsar-external-listener-33-1] INFO xxxx - Received message with 2:61:-1
[pulsar-external-listener-33-1] INFO xxxx - Received message with 2:62:-1

Error messages


Reproducing the issue

Run the cluster with the above mentioned configuration, with a docker compose and not pulsar standalone.

Add the same configuration as mentioned above and try to run a producer and consumer with a near-expiry JWT token.

Additional information

No response

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Activity

  1. added
    type/bug
    on Dec 10, 2025
  2. lhotari commented on Dec 12, 2025

    @lhotari
    Member

    2. 5. authenticateOriginalAuthData: false

    This seems to be the problem. #7824 (comment)

  3. lhotari commented on Dec 12, 2025

    @lhotari
    Member

    [Bug] [Pulsar-Client] Client says disconnected but producer and consumer can still produce/consume messages

    The reason for this behavior is that in the case of using Pulsar Proxy, there will be a separate lookup connection to the proxy and separate data connections via the Proxy to brokers. The proxy won't intercept the traffic for data connections after the handshake is complete. That's why it's necessary to enable authenticateOriginalAuthData on brokers for token expiration check to work.

  4. shasank112001 commented on Dec 12, 2025

    @shasank112001
    ContributorAuthor

    But then I believe we should document this, as authenticateOriginalAuthData is incompatible with mTLS, as proxies can only do reencrypt traffic.

  5. lhotari commented on Dec 12, 2025

    @lhotari
    Member

    But then I believe we should document this, as authenticateOriginalAuthData is incompatible with mTLS, as proxies can only do reencrypt traffic.

    Yes, contributions to improve the documentation are welcome!

    Renaming the issue would also be useful since "Client says disconnected but producer and consumer can still produce/consume messages" isn't a bug.
    It's likely that the mTLS use case isn't supported currently with token expiration check. We could also close this current issue and have a new one for the real gap.

  6. shasank112001 commented on Dec 12, 2025

    @shasank112001
    ContributorAuthor

    I think creating a new Issue with a feature tag would be best. I will create one and close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions