rust-libp2p icon indicating copy to clipboard operation
rust-libp2p copied to clipboard

Confusing PING tutorial

Open rvalle opened this issue 1 year ago • 2 comments

Description

The ping example is confusing.

Running the example will print 2 ping events and silently close the connection:

Dialed /ip4/127.0.0.1/tcp/38703
Listening on "/ip4/127.0.0.1/tcp/34425"
Event { peer: PeerId("12D3KooWH7hh4pun3YE3fWK3XF1PgVd1x3VX9pVWLR3RM1TGLXD9"), connection: ConnectionId(1), result: Ok(87.381113ms) }
Event { peer: PeerId("12D3KooWH7hh4pun3YE3fWK3XF1PgVd1x3VX9pVWLR3RM1TGLXD9"), connection: ConnectionId(1), result: Ok(43.618339ms) }

The expectation set is that the nodes will start "pinging each other every 15 seconds". So I kept wondering if my setup was broken or what...

After modifying the example, I noticed that, what happens is:

ConnectionId ConnectionId(1) closed cause KeepAliveTimeout

So, the connection is closed after 30 seconds regardless of the ping activity.

I propose increasing the timeout to 300 seconds and adding the connection termination reason.

Motivation

the tutorial is confusing, it is difficult to asses if the sample code works or not.

Current Implementation

only to pings and sent, and then the example freezes.

Are you planning to do it yourself in a pull request ?

Yes

rvalle avatar Feb 20 '24 13:02 rvalle

ok, looks like this was already fixed.

rvalle avatar Feb 20 '24 13:02 rvalle

I see now, it is fixed in the example file but not in the tutorial code, which is what I followed.

rvalle avatar Feb 20 '24 13:02 rvalle

With #5176 merged, can we close this issue now?

drHuangMHT avatar Mar 19 '24 03:03 drHuangMHT

sorry yes.

rvalle avatar Mar 19 '24 07:03 rvalle