Skip to content

Commit

Permalink
check err
Browse files Browse the repository at this point in the history
  • Loading branch information
mkuratczyk committed Dec 2, 2024
1 parent c6b6c5b commit 703e262
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion pkg/mqtt_client/consumer_v5.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ func (c Mqtt5Consumer) Start(ctx context.Context, subscribed chan bool) {
if err != nil {
log.Error("consumer connection failed", "id", c.Id, "error", err)
}
c.Connection.AwaitConnection(ctx)
err = c.Connection.AwaitConnection(ctx)
if err != nil {
// AwaitConnection only returns an error if the context is cancelled
return
}
close(subscribed)

// TODO: currently we can consume more than ConsumerCount messages
Expand Down
6 changes: 5 additions & 1 deletion pkg/mqtt_client/publisher_v5.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ func (p *Mqtt5Publisher) Connect(ctx context.Context) {
if err != nil {
log.Error("publisher connection failed", "id", p.Id, "error", err)
}
connection.AwaitConnection(ctx)
err = connection.AwaitConnection(ctx)
if err != nil {
// AwaitConnection only returns an error if the context is cancelled
return
}
p.Connection = connection
}

Expand Down

0 comments on commit 703e262

Please sign in to comment.