diff --git a/peer/server.go b/peer/server.go index 433a6dd..7f49e23 100644 --- a/peer/server.go +++ b/peer/server.go @@ -7,6 +7,7 @@ import ( "encoding/json" "io" "net" + "strings" "time" "github.com/lbryio/reflector.go/reflector" @@ -134,20 +135,6 @@ func (s *Server) handleConnection(conn net.Conn) { log.Error(errors.FullTrace(err)) } - //if strings.Contains(string(request), `"requested_blobs"`) { - // log.Debugln("received availability request") - // response, err = s.handleAvailabilityRequest(request) - //} else if strings.Contains(string(request), `"blob_data_payment_rate"`) { - // log.Debugln("received rate negotiation request") - // response, err = s.handlePaymentRateNegotiation(request) - //} else if strings.Contains(string(request), `"requested_blob"`) { - // log.Debugln("received blob request") - // response, err = s.handleBlobRequest(request) - //} else { - // log.Errorln("invalid request") - // spew.Dump(request) - // return - //} response, err = s.handleCompositeRequest(request) if err != nil { log.Error(err) @@ -161,7 +148,9 @@ func (s *Server) handleConnection(conn net.Conn) { n, err := conn.Write(response) if err != nil { - s.logError(err) + if !strings.Contains(err.Error(), "connection reset by peer") { // means the other side closed the connection using TCP reset + s.logError(err) + } return } else if n != len(response) { log.Errorln(io.ErrShortWrite) diff --git a/reflector/stats.go b/reflector/stats.go index c41c964..ca066a8 100644 --- a/reflector/stats.go +++ b/reflector/stats.go @@ -73,13 +73,13 @@ func (s *Stats) AddError(e error) (shouldLog bool) { // shouldLog is a hack, but } err := errors.Wrap(e, 0) name := err.TypeName() - if strings.Contains(err.Error(), "i/o timeout") { + if strings.Contains(err.Error(), "i/o timeout") { // hit a read or write deadline name = "i/o timeout" - } else if strings.Contains(err.Error(), "read: connection reset by peer") { + } else if strings.Contains(err.Error(), "read: connection reset by peer") { // the other side closed the connection using TCP reset name = "read conn reset" - } else if strings.Contains(err.Error(), "unexpected EOF") { + } else if strings.Contains(err.Error(), "unexpected EOF") { // tried to read from closed pipe or socket name = "unexpected EOF" - } else if strings.Contains(err.Error(), "write: broken pipe") { + } else if strings.Contains(err.Error(), "write: broken pipe") { // tried to write to a pipe or socket that was closed by the peer name = "write broken pipe" } else { shouldLog = true