Skip to content

Commit

Permalink
Add check for null connection before closing
Browse files Browse the repository at this point in the history
  • Loading branch information
kazeborja committed Jan 26, 2022
1 parent 980700f commit daf358e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions stomp.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ func NewStompConnection(username string, password string,
// handleReconnect reconnects to the stomp server
func (session *StompSession) handleReconnect() {
// Close the current session
err := session.conn.Disconnect()
if err != nil {
log.Errorln("Error handling the diconnection:", err.Error())
if session.conn != nil {
err := session.conn.Disconnect()
if err != nil {
log.Errorln("Error handling the diconnection:", err.Error())
}
}

reconnectLoop:
Expand Down

0 comments on commit daf358e

Please sign in to comment.