Keeping IPFS connections alive

We’ve been working on our code that keeps IPFS connected to peers recently. Connections are made in a Shared Worker in the Fission Auth Lobby that handles IPFS connections for all apps that use webnative.

Here are some early results from our upcoming implementation.

This screenshot shows a connections to IPFS peers that are a bit flaky. We track connection status, last connection timestamp, and latency for each peer. The “offline” log message is true if no peers are connected. The “last connected at” log message indicates the last time we could connect to a peer (only accurate when all peers are offline), and “average latency” is the average latency of peers that we can connect to.

The connection strategy is Fibonacci backoff until connected, a keep alive interval of one minute when connected, and a “keep trying” interval of five minutes when backoff has failed, but we want to keep trying occasionally.

The above screenshot is in the Shared Worker, but we have implemented this all in a proof-of-concept repository that you can clone and try for yourself: GitHub - fission-suite/ipfs-connection-poc: A proof of concept environment for testing IPFS peer connections.