do not close relay connection when ping fails because some relays just do not pong.
This commit is contained in:
3
relay.go
3
relay.go
@@ -9,6 +9,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
@@ -187,7 +188,7 @@ func (r *Relay) ConnectWithTLS(ctx context.Context, tlsConfig *tls.Config) error
|
|||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
if r.Connection != nil {
|
if r.Connection != nil {
|
||||||
err := r.Connection.Ping(r.connectionContext)
|
err := r.Connection.Ping(r.connectionContext)
|
||||||
if err != nil {
|
if err != nil && !strings.Contains(err.Error(), "failed to wait for pong") {
|
||||||
InfoLogger.Printf("{%s} error writing ping: %v; closing websocket", r.URL, err)
|
InfoLogger.Printf("{%s} error writing ping: %v; closing websocket", r.URL, err)
|
||||||
r.Close() // this should trigger a context cancelation
|
r.Close() // this should trigger a context cancelation
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user