Skip to content

Commit

Permalink
Merge pull request #335 from litmusautomation/freezeOnConnectionLost
Browse files Browse the repository at this point in the history
Correcting behavior when WriteTimout is 0.
  • Loading branch information
Al S-M committed Jul 17, 2019
2 parents 6963191 + cdf920f commit 9bb3615
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion client.go
Expand Up @@ -599,9 +599,13 @@ func (c *client) Publish(topic string, qos byte, retained bool, payload interfac
DEBUG.Println(CLI, "storing publish message (reconnecting), topic:", topic)
} else {
DEBUG.Println(CLI, "sending publish message, topic:", topic)
publishWaitTimeout := c.options.WriteTimeout
if publishWaitTimeout == 0 {
publishWaitTimeout = time.Second * 30
}
select {
case c.obound <- &PacketAndToken{p: pub, t: token}:
case <-time.After(c.options.WriteTimeout):
case <-time.After(publishWaitTimeout):
token.setError(errors.New("publish was broken by timeout"))
}
}
Expand Down

0 comments on commit 9bb3615

Please sign in to comment.