From a4acde6d9541de0ab2c00d941acfa0d92cb368e3 Mon Sep 17 00:00:00 2001 From: Alexey Khit Date: Sun, 21 Aug 2022 17:26:27 +0300 Subject: [PATCH] Fix two connections to Dahua camera simultaniosly --- pkg/rtsp/conn.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/rtsp/conn.go b/pkg/rtsp/conn.go index 574d3d09..d4d51da7 100644 --- a/pkg/rtsp/conn.go +++ b/pkg/rtsp/conn.go @@ -189,7 +189,7 @@ func (c *Conn) Do(req *tcp.Request) (*tcp.Response, error) { } if res.StatusCode != http.StatusOK { - return nil, fmt.Errorf("wrong response on %s", req.Method) + return res, fmt.Errorf("wrong response on %s", req.Method) } return res, nil @@ -261,7 +261,14 @@ func (c *Conn) Describe() error { res, err := c.Do(req) if err != nil { - return err + if res != nil { + // if we have answer - give second chanse without onvif header + req.Header.Del("Require") + res, err = c.Do(req) + } + if err != nil { + return err + } } if val := res.Header.Get("Content-Base"); val != "" {