fix pinging relays: use the main relay context, not the relay connection temporary context.

This commit is contained in:
fiatjaf
2025-01-17 14:08:54 -03:00
parent 06a15fdaab
commit 3e1c0ddc7e
3 changed files with 10 additions and 7 deletions

View File

@@ -186,7 +186,7 @@ func (r *Relay) ConnectWithTLS(ctx context.Context, tlsConfig *tls.Config) error
select {
case <-ticker.C:
if r.Connection != nil {
err := r.Connection.Ping(ctx)
err := r.Connection.Ping(r.connectionContext)
if err != nil {
InfoLogger.Printf("{%s} error writing ping: %v; closing websocket", r.URL, err)
r.Close() // this should trigger a context cancelation
@@ -213,6 +213,7 @@ func (r *Relay) ConnectWithTLS(ctx context.Context, tlsConfig *tls.Config) error
for {
buf.Reset()
if err := conn.ReadMessage(r.connectionContext, buf); err != nil {
r.ConnectionError = err
r.close(err)