Skip to content

Commit 3730ecf

Browse files
committed
Log response info duriung websocket handshake failure
1 parent 5470a4b commit 3730ecf

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

websocket.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package mqtt
22

33
import (
44
"crypto/tls"
5+
"fmt"
56
"io"
67
"net"
78
"net/http"
@@ -44,8 +45,11 @@ func NewWebsocket(host string, tlsc *tls.Config, timeout time.Duration, requestH
4445
WriteBufferSize: options.WriteBufferSize,
4546
}
4647

47-
ws, _, err := dialer.Dial(host, requestHeader)
48+
ws, resp, err := dialer.Dial(host, requestHeader)
4849

50+
if resp != nil {
51+
WARN.Println(CLI, fmt.Sprintf("Websocket handshake failure. StatusCode: %d. Body: %s", resp.StatusCode, resp.Body))
52+
}
4953
if err != nil {
5054
return nil, err
5155
}

0 commit comments

Comments
 (0)