diff --git a/pkg/servicedisc/autoconnect.go b/pkg/servicedisc/autoconnect.go index 5b6b79d299..26f5aa25d5 100644 --- a/pkg/servicedisc/autoconnect.go +++ b/pkg/servicedisc/autoconnect.go @@ -2,6 +2,8 @@ package servicedisc import ( "context" + "errors" + "io" "net/http" "time" @@ -81,7 +83,9 @@ func (a *autoconnector) Run(ctx context.Context) (err error) { a.log.WithField("pk", pk).WithField("attempt", val).Debugln("Trying to add transport to public visor") logger := a.log.WithField("pk", pk).WithField("type", string(network.STCPR)) if err = a.tryEstablishTransport(ctx, pk, logger); err != nil { - logger.WithError(err).Warnln("Failed to add transport to public visor") + if !errors.Is(err, io.ErrClosedPipe) { + logger.WithError(err).Warnln("Failed to add transport to public visor") + } failedAddresses[pk]++ continue } diff --git a/pkg/transport/network/client.go b/pkg/transport/network/client.go index d15a323c39..ba6bbf9ce8 100644 --- a/pkg/transport/network/client.go +++ b/pkg/transport/network/client.go @@ -6,6 +6,7 @@ import ( "fmt" "io" "net" + "strings" "sync" "github.com/skycoin/dmsg" @@ -150,6 +151,12 @@ func (c *genericClient) acceptTransports(lis net.Listener) { if errors.Is(err, io.EOF) { continue // likely it's a dummy connection from service discovery } + + if c.isClosed() && (errors.Is(err, io.ErrClosedPipe) || strings.Contains(err.Error(), "use of closed network connection")) { + c.log.Info("Cleanly stopped serving.") + return + } + c.log.Warnf("failed to accept incoming connection: %v", err) if !handshake.IsHandshakeError(err) { c.log.Warnf("stopped serving")