Skip to content

Commit

Permalink
Don't attempt to read from conn if closed (#3913)
Browse files Browse the repository at this point in the history
Signed-off-by: Nikki Attea <nikki@sensu.io>
  • Loading branch information
Nikki Attea committed Aug 5, 2020
1 parent 0c01649 commit 4947298
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions backend/agentd/agentd.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,11 @@ func New(c Config, opts ...Option) (*Agentd, error) {
// Capture the log entries from agentd's HTTP server
ErrorLog: log.New(&logrusIOWriter{entry: logger}, "", 0),
ConnState: func(c net.Conn, cs http.ConnState) {
var msg []byte
if _, err := c.Read(msg); err != nil {
logger.WithError(err).Error("websocket connection error")
if cs != http.StateClosed {
var msg []byte
if _, err := c.Read(msg); err != nil {
logger.WithError(err).Error("websocket connection error")
}
}
},
}
Expand Down

0 comments on commit 4947298

Please sign in to comment.