Cardata: fix mqtt receive and logging

This commit is contained in:
andig 2025-10-10 15:40:56 +02:00
parent eeda65858c
commit 0940b325f6
2 changed files with 3 additions and 2 deletions

View file

@ -6,6 +6,7 @@ import (
"encoding/hex"
"errors"
"fmt"
"net/http"
"net/url"
"strings"
"sync"
@ -111,7 +112,7 @@ func NewOauth(ctx context.Context, name, device string, oc *oauth2.Config, opts
log := util.NewLogger("oauth-" + hash)
if ctx.Value(oauth2.HTTPClient) == nil {
if client, ok := ctx.Value(oauth2.HTTPClient).(*http.Client); client == nil || !ok {
ctx = context.WithValue(ctx, oauth2.HTTPClient, request.NewClient(log))
}

View file

@ -115,7 +115,7 @@ func (v *MqttConnector) runMqtt(ctx context.Context, token *oauth2.Token) error
}
defer paho.Disconnect(1000)
topic := fmt.Sprintf("%s/#", gcid)
topic := fmt.Sprintf("%s/+", gcid)
if t := paho.Subscribe(topic, 0, v.handler); !t.WaitTimeout(timeout) {
return errors.New("subcribe timeout")