Skip to content

Commit 49546b1

Browse files
committed
Remove hardcoded publish timeout
Signed-off-by: Dariusz Górecki <[email protected]>
1 parent 77d5b88 commit 49546b1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

protocol/mqttv3_paho/mqttv3.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"fmt"
77
"io"
88
"sync"
9-
"time"
109

1110
mqtt "github.com/eclipse/paho.mqtt.golang"
1211

@@ -104,13 +103,15 @@ func (p *Protocol) Send(ctx context.Context, m binding.Message, transformers ...
104103
}
105104

106105
token := p.client.Publish(topic, p.qos, p.retained, payload)
107-
if !token.WaitTimeout(time.Minute) {
108-
err = fmt.Errorf("publish to %q: timeout", topic)
106+
107+
<-token.Done()
108+
if token.Error() != nil {
109+
err = fmt.Errorf("publish to %q: %w", topic, token.Error())
109110
logger.Error(err)
110111
return err
111112
}
112113

113-
return token.Error()
114+
return nil
114115
}
115116

116117
func (p *Protocol) OpenInbound(ctx context.Context) error {

0 commit comments

Comments
 (0)