ConnClient: fix i/o timeout

This commit is contained in:
aler9
2020-08-17 18:49:25 +02:00
parent c889483a7a
commit b45d2000a6

View File

@@ -577,26 +577,10 @@ func (c *ConnClient) Play(u *url.URL) (*Response, error) {
// the TCP connection open through keepalives, and returns when the TCP
// connection closes.
func (c *ConnClient) LoopUdp(u *url.URL) error {
// send a first keepalive before starting reading
_, err := c.Do(&Request{
Method: OPTIONS,
Url: &url.URL{
Scheme: "rtsp",
Host: u.Host,
User: u.User,
Path: "/",
},
SkipResponse: true,
})
if err != nil {
c.nconn.Close()
return err
}
readDone := make(chan error)
go func() {
for {
c.nconn.SetReadDeadline(time.Now().Add(clientUdpKeepalivePeriod))
c.nconn.SetReadDeadline(time.Now().Add(clientUdpKeepalivePeriod + c.conf.ReadTimeout))
_, err := ReadResponse(c.br)
if err != nil {
readDone <- err