From a7545e6cac23b0d3b0bdfc689f0bee74d9284550 Mon Sep 17 00:00:00 2001 From: Greg Linton Date: Mon, 2 Jul 2018 18:56:58 -0600 Subject: [PATCH] Don't close connection if readTimeout exceeded --- plugins/inputs/syslog/syslog.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/plugins/inputs/syslog/syslog.go b/plugins/inputs/syslog/syslog.go index 3c920d261..a88c06216 100644 --- a/plugins/inputs/syslog/syslog.go +++ b/plugins/inputs/syslog/syslog.go @@ -296,12 +296,16 @@ func (s *Syslog) handle(conn net.Conn, acc telegraf.Accumulator) { // read to the tmp var n, err := conn.Read(tmp) if err != nil { - // Ignore known/recoverable errors. In contrived tests: - // * i/o timeout error - no data to Read() before s.ReadTimeout.Duration expired - // * EOF error - connection open/close immediately - if er, ok := err.(net.Error); err != io.EOF && (ok && !er.Timeout()) { - s.store(rfc5425.Result{Error: fmt.Errorf("Failed reading from syslog client - %s", err.Error())}, acc) + // read timeout reached, retry + if er, ok := err.(net.Error); ok && er.Timeout() { + continue } + // client has closed connection, return + if err == io.EOF { + return + } + // other error, log and return + s.store(rfc5425.Result{Error: fmt.Errorf("failed reading from syslog client - %s", err.Error())}, acc) return }