Skip to content

Commit

Permalink
Merge pull request #353 from alsm/master
Browse files Browse the repository at this point in the history
check conn before closing
  • Loading branch information
Al S-M committed Aug 29, 2019
2 parents c49ea09 + f6b1d90 commit a436547
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions client.go
Expand Up @@ -405,8 +405,10 @@ func (c *client) reconnect() {

rc, _ = c.connect()
if rc != packets.Accepted {
c.conn.Close()
c.conn = nil
if c.conn != nil {
c.conn.Close()
c.conn = nil
}
//if the protocol version was explicitly set don't do any fallback
if c.options.protocolVersionExplicit {
ERROR.Println(CLI, "Connecting to", broker, "CONNACK was not Accepted, but rather", packets.ConnackReturnCodes[rc])
Expand Down

0 comments on commit a436547

Please sign in to comment.