mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-03-17 21:32:56 +01:00
do not close relay connection when ping fails because some relays just do not pong.
This commit is contained in:
parent
6daecc8bd2
commit
17431dee59
3
relay.go
3
relay.go
@ -9,6 +9,7 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
@ -187,7 +188,7 @@ func (r *Relay) ConnectWithTLS(ctx context.Context, tlsConfig *tls.Config) error
|
||||
case <-ticker.C:
|
||||
if r.Connection != nil {
|
||||
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)
|
||||
r.Close() // this should trigger a context cancelation
|
||||
return
|
||||
|
Loading…
x
Reference in New Issue
Block a user