Connection management #3670
-
Hey! I'm trying to better understand the concept of connections in libp2p. Few questions:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
All excellent questions!
Technically, it is enough. Practically, you can't avoid it. How would you decide which connection to keep if two peers dial each other at the same time?
This function is deprecated in master already, see #3386. You can set it to 1 but may experience weird behaviour because both peers may close a different connection and you end up with none.
A The request-respones behaviour in particular uses a round-robin approach across all active connections:
Behaviours are organised as "slices", i.e. they all share all connections. Each connection has a connection handler which is again composed out of all the handlers of all behaviours. It is one task per connection but the handlers are composed.
Yes, see: |
Beta Was this translation helpful? Give feedback.
-
Thanks for the response! So is there any benefit of having more than one or two open connections? |
Beta Was this translation helpful? Give feedback.
All excellent questions!
Technically, it is enough. Practically, you can't avoid it. How would you decide which connection to keep if two peers dial each other at the same time?
This functio…