Browse Source

move http.Client.CloseIdleConnections() outside WHIPClient

pull/3124/head
aler9 2 years ago
parent
commit
546e24b4d7
  1. 1
      internal/protocols/webrtc/whip_client.go
  2. 19
      internal/staticsources/webrtc/source.go

1
internal/protocols/webrtc/whip_client.go

@ -210,7 +210,6 @@ outer: @@ -210,7 +210,6 @@ outer:
func (c *WHIPClient) Close() error {
err := WHIPDeleteSession(context.Background(), c.HTTPClient, c.URL.String())
c.pc.Close()
c.HTTPClient.CloseIdleConnections()
return err
}

19
internal/staticsources/webrtc/source.go

@ -40,15 +40,18 @@ func (s *Source) Run(params defs.StaticSourceRunParams) error { @@ -40,15 +40,18 @@ func (s *Source) Run(params defs.StaticSourceRunParams) error {
u.Scheme = strings.ReplaceAll(u.Scheme, "whep", "http")
client := webrtc.WHIPClient{
HTTPClient: &http.Client{
Timeout: time.Duration(s.ReadTimeout),
Transport: &http.Transport{
TLSClientConfig: tls.ConfigForFingerprint(params.Conf.SourceFingerprint),
},
hc := &http.Client{
Timeout: time.Duration(s.ReadTimeout),
Transport: &http.Transport{
TLSClientConfig: tls.ConfigForFingerprint(params.Conf.SourceFingerprint),
},
URL: u,
Log: s,
}
defer hc.CloseIdleConnections()
client := webrtc.WHIPClient{
HTTPClient: hc,
URL: u,
Log: s,
}
tracks, err := client.Read(params.Context)

Loading…
Cancel
Save