Skip to content

Commit

Permalink
Fix: client reconnected every authenticationRefreshCheckSeconds when …
Browse files Browse the repository at this point in the history
…using tls authentication (#1062)

### Motivation

When using pulsar tls authentication with a broker that sets the authenticationRefreshCheckSeconds the connection was dropped for each authentication refresh check. After analyzing logs and tcpdumps I concluded that this error appears because the tls authentication is returning null, witch does not pass a validation in the broker.
After analyzing the tls auth implementation in Java (that works), I concluded that the GetData method should return empty byte array instead of nil.

### Modifications

Changed tls auth GetData to return empty byte array instead of nil.

---------

Co-authored-by: Jorge Pereira <jorge.pereira@cross-join.com>
  • Loading branch information
jffp113 and Jorge Pereira authored Jul 27, 2023
1 parent a3fcc9a commit 16a0299
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pulsar/internal/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,11 @@ func (c *connection) handleAuthChallenge(authChallenge *pb.CommandAuthChallenge)
return
}

// Brokers expect authData to be not nil
if authData == nil {
authData = []byte{}
}

cmdAuthResponse := &pb.CommandAuthResponse{
ProtocolVersion: proto.Int32(PulsarProtocolVersion),
ClientVersion: proto.String(ClientVersionString),
Expand Down

0 comments on commit 16a0299

Please sign in to comment.