Skip to content

Commit

Permalink
Issue #488 - If options.AutoReconnect is true calling Disconnect coul…
Browse files Browse the repository at this point in the history
…d trigger another connection attempt.

Signed-off-by: Matt Brittan <matt@brittan.nz>
  • Loading branch information
MattBrittan committed Feb 24, 2021
1 parent 18bfbde commit a5329ed
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,13 @@ func (c *client) internalConnLost(err error) {
DEBUG.Println(CLI, "internalConnLost waiting on workers")
<-stopDone
DEBUG.Println(CLI, "internalConnLost workers stopped")
if c.options.CleanSession && !c.options.AutoReconnect {
// It is possible that Disconnect was called which led to this error so reconnection depends upon status
reconnect := c.options.AutoReconnect && c.connectionStatus() > connecting

if c.options.CleanSession && !reconnect {
c.messageIds.cleanUp()
}
if c.options.AutoReconnect {
if reconnect {
c.setConnected(reconnecting)
go c.reconnect()
} else {
Expand Down

0 comments on commit a5329ed

Please sign in to comment.