diff --git a/p2p/protocol/ping/ping.go b/p2p/protocol/ping/ping.go index 981b340e08..2d80fe07c7 100644 --- a/p2p/protocol/ping/ping.go +++ b/p2p/protocol/ping/ping.go @@ -60,7 +60,7 @@ func (p *PingService) PingHandler(s network.Stream) { defer close(errCh) timer := time.NewTimer(pingTimeout) defer timer.Stop() - + writes := 0 go func() { select { case <-timer.C: @@ -72,10 +72,9 @@ func (p *PingService) PingHandler(s network.Stream) { log.Error("ping loop failed without error") } } - log.Error("calling ping stream close") + log.Errorln("calling ping stream close", writes) s.Close() }() - for { _, err := io.ReadFull(s, buf) if err != nil { @@ -83,14 +82,13 @@ func (p *PingService) PingHandler(s network.Stream) { errCh <- err return } - time.Sleep(1 * time.Second) _, err = s.Write(buf) if err != nil { log.Error("write failed: ", err) errCh <- err return } - log.Error("one ping done") + writes++ timer.Reset(pingTimeout) } }