diff --git a/p2p/net/conn/dial.go b/p2p/net/conn/dial.go index 8efd7d10b43f25513a7f1f2718506c73d3fbe778..94fd8fcddbdfebaeb121e2f41cf53af1d3145be8 100644 --- a/p2p/net/conn/dial.go +++ b/p2p/net/conn/dial.go @@ -4,6 +4,7 @@ import ( "fmt" "math/rand" "strings" + "time" ci "github.com/ipfs/go-libp2p-crypto" lgbl "github.com/ipfs/go-libp2p-loggables" @@ -68,12 +69,16 @@ func (d *Dialer) Dial(ctx context.Context, raddr ma.Multiaddr, remote peer.ID) ( cryptoProtoChoice = NoEncryptionTag } + maconn.SetReadDeadline(time.Now().Add(NegotiateReadTimeout)) + err = msmux.SelectProtoOrFail(cryptoProtoChoice, maconn) if err != nil { errOut = err return } + maconn.SetReadDeadline(time.Time{}) + c, err := newSingleConn(ctx, d.LocalPeer, remote, maconn) if err != nil { maconn.Close()