Skip to content

Transport Auto Retry Listening #312

Closed
@jacobheun

Description

@jacobheun

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
  • Libp2p emits its change in listening state

2. Wifi Connection Drops

TODO

3. Computer sleep

TODO

Notes

Transports

States

  1. Closed - All listeners are closed
  2. Connecting - Initial listening attempts are being made
  3. Retry - Listening failed, retry will occur automatically and is manually triggerable
  4. Retrying - Attempting to listen again
  5. Listening - Listeners are active
  6. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    exp/expertHaving worked on the specific codebase is importantkind/enhancementA net-new feature or improvement to an existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions