Open iwanbk opened 5 months ago
Some research has been done to other platform about how they handle network state event.
yggdrasil
only handle onAvailable
event
If we follow the code, it will call their Go engine
https://github.com/yggdrasil-network/yggdrasil-go/blob/v0.5.5/contrib/mobile/mobile.go#L183-L186
// Retry resets the peer connection timer and tries to dial them immediately.
func (m *Yggdrasil) RetryPeersNow() {
m.core.RetryPeersNow()
}
from the comment and quick read, looks like yggdrasil
resets all the connections.
I think this way is quite simple and reliable
I also looked at wireguard-android and found nothing so far.
But i found that wireguard-apple
do have the handles as i mentioned in https://github.com/threefoldtech/myceliumflut/issues/35#issuecomment-2138686759
To summarize, wireguard-apple
do these:
wireguard
wireguard
started
: bump sockets:
looks like yggdrasil resets all the connections.
network available when wireguard state is started: bump sockets:
- close existing socket
- re-open socket
- send keepalive to peers
All of above things are done in their respective engine (yggdrasil-go and wireguard-go), so we might need to do that as well in mycelium
The NetworkCallback
already added and below are my observations:
NetworkCallback
eventmycelium
can handle network lost -> available perfectlyFor now i will push the NetworkCallback
code but only in listening mode, no specific actions taken when any events fired
Mobile phone have certain behaviors that different with server or PC/laptop: connection lost (and connected again) is not uncommon, for many reasons.
While
mycelium
should already handle connection lost, there are more about it in mobile phone:mycelium
disconnected while we thought that it should be connectedAndroid has builtin class for this :
NetworkCallback
. It can give notification for various network state changes events: