Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions client_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,15 @@ func (c *clientHandler) readCommand() bool {
if c.server.settings.IdleTimeout > 0 {
if err := c.conn.SetDeadline(
time.Now().Add(time.Duration(time.Second.Nanoseconds() * int64(c.server.settings.IdleTimeout)))); err != nil {
// If the connection is already closed, return early instead of trying to read
if isClosedConnError(err) {
if c.debug {
c.logger.Debug("Client disconnected before first command")
}

return true
}

c.logger.Error("Network error", "err", err)
}
}
Expand Down Expand Up @@ -525,11 +534,29 @@ func (c *clientHandler) handleCommandsStreamError(err error) bool {
return true
}

// Check if this is a closed connection error - treat as normal disconnect
if isClosedConnError(err) {
if c.debug {
c.logger.Debug("Client disconnected", "clean", false)
}

return true
}

c.logger.Error("Network error", "err", err)

return true
}

// Check for closed connection errors before logging as error
if isClosedConnError(err) {
if c.debug {
c.logger.Debug("Client disconnected", "clean", false)
}

return true
}

if errors.Is(err, io.EOF) {
if c.debug {
c.logger.Debug("Client disconnected", "clean", false)
Expand Down
Loading