Repository navigation
Description
Describe the bug
Connection layer of Java client keeps on trying (and failing to) reconnect to broker when access token used to authenticate expires.
It seems that connection pool handles connections transparently in the background even if all consumers/readers are closed.
To reproduce it create a consumer with a Pulsar with security (JWT auth) enabled. Use a short-lived token (a few minutes). Once token has expired now and then connection times out and pool tries to reconnect it (even if no consumers/readers are present). Then we will see periodically in log these entries:
2020-12-11 14:25:38.342 INFO 29332 --- [sar-timer-139-1] o.a.p.client.impl.ConnectionHandler : [persistent://dbus/test/dummy-objects] [reader-0f59ce70b0] Reconnecting after connection was closed
2020-12-11 14:25:38.344 INFO 29332 --- [client-io-136-1] o.a.pulsar.client.impl.ConnectionPool : [[id: 0xf03136ce, L:/127.0.0.1:52383 - R:localhost/127.0.0.1:6650]] Connected to server
2020-12-11 14:25:38.348 WARN 29332 --- [client-io-136-1] org.apache.pulsar.client.impl.ClientCnx : [id: 0xf03136ce, L:/127.0.0.1:52383 - R:localhost/127.0.0.1:6650] Received error from server: Unable to authenticate
2020-12-11 14:25:38.348 WARN 29332 --- [client-io-136-1] o.a.pulsar.client.impl.ConnectionPool : [[id: 0xf03136ce, L:/127.0.0.1:52383 - R:localhost/127.0.0.1:6650]] Connection handshake failed: org.apache.pulsar.client.api.PulsarClientException$AuthenticationException: Unable to authenticate
2020-12-11 14:25:38.348 WARN 29332 --- [client-io-136-1] o.a.p.client.impl.ConnectionHandler : [persistent://dbus/test/dummy-objects] [reader-0f59ce70b0] Error connecting to broker: org.apache.pulsar.client.api.PulsarClientException$AuthenticationException: Unable to authenticate
2020-12-11 14:25:38.348 WARN 29332 --- [client-io-136-1] o.a.p.client.impl.ConnectionHandler : [persistent://dbus/test/dummy-objects] [reader-0f59ce70b0] Could not get connection to broker: org.apache.pulsar.client.api.PulsarClientException$AuthenticationException: Unable to authenticate -- Will try again in 57.76 s
2020-12-11 14:25:38.348 ERROR 29332 --- [client-io-136-1] org.apache.pulsar.client.impl.ClientCnx : [id: 0xf03136ce, L:/127.0.0.1:52383 ! R:localhost/127.0.0.1:6650] Failed to authenticate the client
2020-12-11 14:25:38.348 WARN 29332 --- [client-io-136-1] org.apache.pulsar.client.impl.ClientCnx : [id: 0xf03136ce, L:/127.0.0.1:52383 ! R:localhost/127.0.0.1:6650] Received unknown request id from server: -1
2020-12-11 14:25:38.348 INFO 29332 --- [client-io-136-1] org.apache.pulsar.client.impl.ClientCnx : [id: 0xf03136ce, L:/127.0.0.1:52383 ! R:localhost/127.0.0.1:6650] Disconnected
To Reproduce
Enable JWT based authentication and issue a short-lived token. Publish and consume some messages using that token. Wait a few minutes until token expires.
Expected behavior
Connection pool should not try to reconnect (or at least retry only a few times) when authentication fails.
Screenshots
Desktop (please complete the following information):
- Windows (Docker Desktop)
Additional context
Activity
frankjkelly commentedon May 26, 2021
Any chance this is related to #7927 - at least insofar as the reconnections bit?
tisonkun commentedon Dec 9, 2022
Closed as stale. Please create a new issue if it's still relevant to the maintained versions.