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}) } }