From 2fd5fa5beece3cecaea3ad35329afe339b360909 Mon Sep 17 00:00:00 2001 From: Nikolay Pavlovich Date: Wed, 7 Sep 2022 02:17:36 +0300 Subject: [PATCH 1/2] add dial start logging --- recws.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/recws.go b/recws.go index 1ad0b83..3c667b5 100644 --- a/recws.go +++ b/recws.go @@ -451,6 +451,9 @@ func (rc *RecConn) connect() { for { nextItvl := b.Duration() + if !rc.getNonVerbose() { + rc.log(LogValues{Msg: "Dial: start", Url: rc.url}) + } wsConn, httpResp, err := rc.dialer.Dial(rc.url, rc.reqHeader) rc.mu.Lock() From aef9c37b74ad3a4b35ba7ce1f9bbd9e75251f6b6 Mon Sep 17 00:00:00 2001 From: Nikolay Pavlovich Date: Wed, 7 Sep 2022 23:34:33 +0300 Subject: [PATCH 2/2] fix logging --- recws.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/recws.go b/recws.go index 3c667b5..c77c021 100644 --- a/recws.go +++ b/recws.go @@ -325,11 +325,12 @@ func (rc *RecConn) SetTLSClientConfig(tlsClientConfig *tls.Config) { // the origin (Origin), subprotocols (Sec-WebSocket-Protocol) and cookies // (Cookie). Use GetHTTPResponse() method for the response.Header to get // the selected subprotocol (Sec-WebSocket-Protocol) and cookies (Set-Cookie). -func (rc *RecConn) Dial(urlStr string, reqHeader http.Header) { +func (rc *RecConn) Dial(urlStr string, reqHeader http.Header) error { urlStr, err := rc.parseURL(urlStr) if err != nil { rc.log(LogValues{Msg: "Dial", Err: err, Fatal: true}) + return err } // Config @@ -347,6 +348,7 @@ func (rc *RecConn) Dial(urlStr string, reqHeader http.Header) { // wait on first attempt time.Sleep(rc.getHandshakeTimeout()) + return nil } // GetURL returns current connection url @@ -471,8 +473,7 @@ func (rc *RecConn) connect() { if rc.hasSubscribeHandler() { if err := rc.SubscribeHandler(); err != nil { rc.log(LogValues{Msg: "Dial: connect handler failed", Err: err, Fatal: true}) - } - if !rc.getNonVerbose() { + } else if !rc.getNonVerbose() { rc.log(LogValues{Msg: "Dial: connect handler was successfully established", Url: rc.url}) } }