ensure relay context and subscriptions are closed when we lose connectivity.

This commit is contained in:
fiatjaf
2023-05-30 17:44:25 -03:00
parent 19d96e3566
commit 9cafea7e2a
3 changed files with 15 additions and 16 deletions

View File

@ -162,7 +162,8 @@ func TestConnectWithOrigin(t *testing.T) {
defer ws.Close()
// relay client
r := &Relay{URL: NormalizeURL(ws.URL), RequestHeader: http.Header{"origin": {"https://example.com"}}}
r := NewRelay(context.Background(), NormalizeURL(ws.URL))
r.RequestHeader = http.Header{"origin": {"https://example.com"}}
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
err := r.Connect(ctx)