Closed
Description
This has been brought up in several different issues across libp2p and js-ipfs. We need to be able to handle unstable listening of transports, and report that back to consumers of the libp2p api.
Goals
- Support intermittent availability of listening connections, such as for remote listening.
- Allow for automatic retry of connections when offline.
- Add hooks for developers to check connectivity status.
Needed Updates
- Update interface-transport to allow for multi address listening
- Update interface-transport to handle automatic retry of listening with jitter
- Update interface-transport to take an option for overriding retry
- Update interface-transport to take an option failure tolerance (error_all_failed, error_some_failed, always_retry)
- Update switch to use the new interface-transport api
- Update all transports to the new interface-transport api
- Update libp2p to expose the retry interface and necessary configurations
Scenarios
1. Websocket browser node starts offline
- The node starts and no listening connections are able to be made
- The websocket transport emits
ERROR_ALL_LISTENERS_FAILED
- Switch is configured to not fatally error on listener failures
- Switch tracks the error state of each transport type (websocket in state
Retry
) - The state includes metadata for the retry logic (when is the next retry)
- The websocket transport automatically retries after a TBD backoff interval
- After x attempts, websocket is able to listen
- The websocket transport emits a state change of
Listening
- Switch updates the listening status of the websocket transport via its TransportManager
- Switch emits the change in its listening status as it now has an active listener
- The websocket transport emits a state change of
- Libp2p emits its change in listening state
2. Wifi Connection Drops
TODO
3. Computer sleep
TODO
Notes
Transports
States
- Closed - All listeners are closed
- Connecting - Initial listening attempts are being made
- Retry - Listening failed, retry will occur automatically and is manually triggerable
- Retrying - Attempting to listen again
- Listening - Listeners are active
- Closing - Listeners are being closed
Reference Issues
ipfs/js-ipfs#1837
https://github.com/libp2p/interface-transport/issues/41
libp2p/js-libp2p-websocket-star#61