recws-org / recws

Reconnecting WebSocket is a websocket client based on gorilla/websocket that will automatically reconnect if the connection is dropped and keeps the connection alive - thread safe!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

KeepAlive implementation seems incorrect

water-a opened this issue · comments

     ticker            = time.NewTicker(rc.getKeepAliveTimeout())

...

if err := rc.writeControlPingMessage(); err != nil {
    log.Println(err)
}

<-ticker.C
if time.Since(keepAliveResponse.getLastResponse()) > rc.getKeepAliveTimeout() {
    rc.CloseAndReconnect()
    return
}

Shouldn't time.Since(keepAliveResponse.getLastResponse()) always be greater than keepAliveTimeout because it's waiting on the timer which is set to keepAliveTimeout???

I'm encountering the situation where the time since the last response is ever so slightly longer than keepAliveTimeout.