Fix #406: reconnect() can be called while still connected (#407)

This commit is contained in:
Erik McClure 2017-07-18 18:21:45 -07:00 committed by Chris Rhodes
parent d51cda6e5a
commit 71ede90b56

View file

@ -709,6 +709,13 @@ func (s *Session) reconnect() {
return return
} }
// Certain race conditions can call reconnect() twice. If this happens, we
// just break out of the reconnect loop
if err == ErrWSAlreadyOpen {
s.log(LogInformational, "Websocket already exists, no need to reconnect")
return
}
s.log(LogError, "error reconnecting to gateway, %s", err) s.log(LogError, "error reconnecting to gateway, %s", err)
<-time.After(wait * time.Second) <-time.After(wait * time.Second)