-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(networking): new metric showing if node is reachable #1206
Comments
Thanks. Very helpful and goes a long way towards addressing a common concern from node operators. |
@alrevuelta any concerns if we remove this from |
The proposed feature in the alternatives considered above would be easy to add once the peer store refactor is finished #622. Add a new metric (prometheus + rpc) showing the amount of inbound/outbound peers the node has. This would add a requirement to store the |
As raised by @Menduist, a node can have multiple connections, some being incoming and others outgoing, so perhaps I need to modify this metric. But first I would like to understand this from a practical point of view in waku side. Do we currently support multiple connections with a given peer? If not do we plan to support this in the future? Plan b would be to:
The idea here is to know how well-connected a node is in terms of in/out connections. |
Answering myself. I would say no, and this example should prove why. Let's say we have
The same applies to WebSockets. Tried connecting So would say that as it is a peer can't have multiple connections, since existing ones are reused for i) different protocols and ii) different transports. Edit: let conn1 = await nodes[0].peerManager.dialPeer(peerInfos[1], WakuRelayCodec, 2.seconds)
# I see "Reusing existing connection" in between
let conn2 = await nodes[0].peerManager.dialPeer(peerInfos[1], WakuLightPushCodec, 2.seconds)
# But then, do I get a different connection?
echo "conn1", $conn1.get().protocol # /vac/waku/relay/2.0.0
echo "conn2", $conn2.get().protocol # /vac/waku/lightpush/2.0.0-beta1 |
As explained by @Menduist max connections per peer is currently set to one, but this might change in the future. I will make the default to 1 in our side. If at some point we want to allow multiple connections, we can revisit. |
@diegomrsantos is working in an AutonatService that tells us the Some requirements on our side, with some implications on the service:
|
vacp2p/nim-libp2p#814 is getting close to be ready, but this feature is blocked until it is merged. |
Problem
As discussed with @jm-clius, currently there is no way for the node itself to be aware if it's reachable from the outside by other peers. #754 allows for an external party to check if it is reachable, but the node itself isn't aware of it.
Suggested solution
The libp2p feature autonat allows us to request other peers to dial us, and if the response is ok, the node itself can be sure that it is reachable. Luckily, looks like nim-libp2p support its. More info:
Once we have the value
isNodeReachable
updated periodically, we can use it:false
.Alternatives considered
A less engineered approach would be to just check the number of
inbound
peers and if!=0
consider that the node is reachable. However one can argue that no inbound peers won't strictly mean that were are not reachable. In other words:n_inbound_peers!=0
means that the node is reachablen_inbound_peers=0
doesn't necessarily mean that the node is not reachable. Perhaps in practice yes, but still.Additional context
Acceptance criteria
dialMe
is used and returnsReachable
,NotReachable
,Unknown
. Edit: Reuse AutonatServiceThe text was updated successfully, but these errors were encountered: