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

Log SASL connection and handshake errors #2995

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,9 @@ func (b *Broker) Open(conf *Config) error {
if b.connErr != nil {
err = b.conn.Close()
if err == nil {
DebugLogger.Printf("Closed connection to broker %s\n", b.addr)
DebugLogger.Printf("Closed connection to broker %s due to SASL v0 auth error: %s\n", b.addr, b.connErr)
} else {
Logger.Printf("Error while closing connection to broker %s: %s\n", b.addr, err)
Logger.Printf("Error while closing connection to broker %s (due to SASL v0 auth error: %s): %s\n", b.addr, b.connErr, err)
}
b.conn = nil
atomic.StoreInt32(&b.opened, 0)
Expand All @@ -264,9 +264,9 @@ func (b *Broker) Open(conf *Config) error {
<-b.done
err = b.conn.Close()
if err == nil {
DebugLogger.Printf("Closed connection to broker %s\n", b.addr)
DebugLogger.Printf("Closed connection to broker %s due to SASL v1 auth error: %s\n", b.addr, b.connErr)
} else {
Logger.Printf("Error while closing connection to broker %s: %s\n", b.addr, err)
Logger.Printf("Error while closing connection to broker %s (due to SASL v1 auth error: %s): %s\n", b.addr, b.connErr, err)
}
b.conn = nil
atomic.StoreInt32(&b.opened, 0)
Expand Down Expand Up @@ -1242,12 +1242,12 @@ func (b *Broker) authenticateViaSASLv1() error {

handshakeErr := b.sendInternal(handshakeRequest, prom)
if handshakeErr != nil {
Logger.Printf("Error while performing SASL handshake %s\n", b.addr)
Logger.Printf("Error while performing SASL handshake %s: %s\n", b.addr, handshakeErr)
return handshakeErr
}
handshakeErr = handleResponsePromise(handshakeRequest, handshakeResponse, prom, metricRegistry)
if handshakeErr != nil {
Logger.Printf("Error while performing SASL handshake %s\n", b.addr)
Logger.Printf("Error while handling SASL handshake response %s: %s\n", b.addr, handshakeErr)
return handshakeErr
}

Expand All @@ -1267,7 +1267,7 @@ func (b *Broker) authenticateViaSASLv1() error {
}
authErr = handleResponsePromise(authenticateRequest, authenticateResponse, prom, metricRegistry)
if authErr != nil {
Logger.Printf("Error while performing SASL Auth %s\n", b.addr)
Logger.Printf("Error while performing SASL Auth %s: %s\n", b.addr, authErr)
return nil, authErr
}

Expand Down Expand Up @@ -1385,7 +1385,7 @@ func (b *Broker) sendAndReceiveSASLPlainAuthV0() error {
if b.conf.Net.SASL.Handshake {
handshakeErr := b.sendAndReceiveSASLHandshake(SASLTypePlaintext, b.conf.Net.SASL.Version)
if handshakeErr != nil {
Logger.Printf("Error while performing SASL handshake %s\n", b.addr)
Logger.Printf("Error while performing SASL handshake %s: %s\n", b.addr, handshakeErr)
return handshakeErr
}
}
Expand Down
Loading