diff --git a/wsnet/dial.go b/wsnet/dial.go index 7f00a128..8b7f4a56 100644 --- a/wsnet/dial.go +++ b/wsnet/dial.go @@ -178,7 +178,9 @@ func Dial(ctx context.Context, conn net.Conn, options *DialOptions) (*Dialer, er err = dialer.negotiate(ctx) if err != nil { - return nil, xerrors.Errorf("negotiate rtc connection: %w", err) + // Return the dialer since we have tests that verify things are closed + // if negotiation fails. + return dialer, xerrors.Errorf("negotiate rtc connection: %w", err) } return dialer, nil diff --git a/wsnet/dial_test.go b/wsnet/dial_test.go index 4aa6f195..d57559c3 100644 --- a/wsnet/dial_test.go +++ b/wsnet/dial_test.go @@ -62,7 +62,15 @@ func TestDial(t *testing.T) { defer cancelFunc() dialer, err := DialWebsocket(ctx, connectAddr, nil, nil) require.True(t, errors.Is(err, context.DeadlineExceeded)) + require.NotNil(t, dialer) require.Error(t, dialer.conn.Close(), "already wrote close") + + // Ensure the rtc peer connection is closed. Setting the config options + // to empty struct does nothing, but it does fail if the rtc peer conn + // is closed. + err = dialer.rtc.SetConfiguration(webrtc.Configuration{}) + require.Error(t, err) + require.ErrorIs(t, err, webrtc.ErrConnectionClosed) }) t.Run("Ping", func(t *testing.T) {
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: