Open ghost opened 6 years ago
Is the connection lifecycle documented somewhere? I've looked at the connection spec and it really doesn't talk about it much.
As far as I can tell it's something like this.
dial
ed (no protocol specified)dialProtocol
, once the protocol connection is open the peers have an active Connection
that they can then use to stream data via pull-stream
s.hangUp
on the other peer. (Does this terminate the non-protocol connection as well?)
b. The connection closes at the end of the callback
c. A protocol connection is just "logical" a new connection isn't actually opened, instead it just establishes that the data that comes next over the connection is supposed to be handled via that protocol handler.Any feedback/guidance would be awesome.
Just stumbled on this, the talk @jacobheun gave in August `18 on this exact topic, doh. Now to watch it and see if I can answer my own question.
Edit: The video didn't really answer the question, but the more that I think about it and explore examples, it looks like it must be C, that the Connection
must just be logical and that it's just passing it to the handler for easy access.
@JustMaier This is a great question to bring over to our discussion boards at https://discuss.libp2p.io/.
In short, yes, streams
(protocols) are just logical connections that are multiplexed over a single TCP connection.
Thanks @mgoelzer, I'll be sure to keep questions like this over on the discussion boards. Sorry about that. I'll go ahead and post there just so there's a record.
I'll follow up on the forum but also closing the circle here, there is a WIP spec to better document the language agnostic lifecycle at https://github.com/libp2p/specs/pull/168. We will also be working on the JS specific implementation docs as we improve the api in the coming months.
Presentation: What is the connection flow of a libp2p connection? What happens internally and why?
Your Name: Jacob Heun @jacobheun
Session Type (choose one): Presentation
Duration: 30 minutes
Title (a few words): The life of a libp2p connection
Abstract (1 sentence up to a couple paragraphs, as you prefer):
Libp2p connections have a lot going on. It can be difficult to understand what's going on under the hood, and why it's happening. In this talk we'll cover the lifecycle of a connection, along with the many pieces that work together to form that connection and why they exist.
Attendees should leave with a better holistic understanding of libp2p connections and their lifecycle.