Skip to content

Commit

Permalink
improve web socket error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
luthermonson authored and Craig Jellick committed Aug 29, 2019
1 parent 20a936b commit 93f43c6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/remotedialer/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package remotedialer

import (
"context"
"io/ioutil"
"net/http"
"time"

Expand All @@ -24,12 +25,18 @@ func connectToProxy(proxyURL string, headers http.Header, auth ConnectAuthorizer
if dialer == nil {
dialer = &websocket.Dialer{HandshakeTimeout: 10 * time.Second}
}
ws, _, err := dialer.Dial(proxyURL, headers)
ws, resp, err := dialer.Dial(proxyURL, headers)
if err != nil {
logrus.WithError(err).Error("Failed to connect to proxy")
rb, err2 := ioutil.ReadAll(resp.Body)
if err2 != nil {
logrus.WithError(err).Errorf("Failed to connect to proxy. Response status: %v - %v. Couldn't read response body (err: %v)", resp.StatusCode, resp.Status, err2)
} else {
logrus.WithError(err).Errorf("Failed to connect to proxy. Response status: %v - %v. Response body: %s", resp.StatusCode, resp.Status, rb)
}
return err
}
defer ws.Close()
defer resp.Body.Close()

ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand Down

0 comments on commit 93f43c6

Please sign in to comment.