diff --git a/p2p/conn/connection.go b/p2p/conn/connection.go index 23c8edc9d..7c7cee344 100644 --- a/p2p/conn/connection.go +++ b/p2p/conn/connection.go @@ -332,7 +332,7 @@ FOR_LOOP: c.Logger.Debug("Send Ping") wire.WriteByte(packetTypePing, c.bufWriter, &n, &err) c.sendMonitor.Update(int(n)) - go c.flush() + c.flush() c.Logger.Debug("Starting pong timer") c.pongTimer.Reset(c.config.pongTimeout) case <-c.pongTimer.C: diff --git a/p2p/conn/connection_test.go b/p2p/conn/connection_test.go index 5570331e7..863642113 100644 --- a/p2p/conn/connection_test.go +++ b/p2p/conn/connection_test.go @@ -137,6 +137,11 @@ func TestPongTimeoutResultsInError(t *testing.T) { require.Nil(t, err) defer mconn.Stop() + go func() { + // read ping + server.Read(make([]byte, 1)) + }() + expectErrorAfter := 10*time.Millisecond + mconn.config.pingInterval + mconn.config.pongTimeout select { case msgBytes := <-receivedCh: