Evaluate integration of the web relay #1851
Description
Overview
Some time ago we put together https://github.com/OpenBazaar/webrelay, which is a server designed to:
- Publish offline messages on behalf of other nodes, specifically light clients on web and mobile
- Forward any offline messages published to a node over sockets
This is not to be confused with the IPFS relay that facilitates two online nodes forming a connection for direct interactions. The purpose of the web relay is to make publishing offline messages more reliable, and the detection of offline messages more immediate.
This infrastructure is presently used by Zokos to great effect (kudos @rodkeys). Presently, we've started experimenting how this would work in Haven, and since things are getting more serious, we should capture the work in this issue.
Hypothesis
Our expected utility for this work:
- More reliable publishing of offline messages (i.e. fewer missing order messages, faster offline message delivery)
- Near-instant detection of received offline messages addressed to the node (e.g. chat, order messages)
Phase 1: Feasibility study
We want to evaluate whether our hypothesis :
- 1. Deploy the web relay server
- 2. Create a branch where a socket connection is being made to the web relay server
- 3. Test sending/receiving offline messages using the web relay server
- This includes desktop-desktop, desktop-mobille, desktop-zokos, mobile-zokos, and mobile-mobile messaging
The manner of this implementation will suit quick testing and not production-level code. If our testing demonstates an improvement in offline message publishing and delivery, then we'll move onto phase 2.
Phase 2: Production integration
After looking at the code we prepared in the branch, we will:
- 1. Schedule a call to walk through the code and how it works
- 2. Write up some concrete requirements
- 3. Come to a consensus on how we want to implement this, and any other considerations
- 4. Schedule the development work
- 5. Test and review the code
- 6. Merge and deploy
A parallel discussion needs to happen with the infrastructure team, who will be responsible for maintaining the web relay.
Other considerations
- The web relay is looking promising thus far and could significantly improve the reliability of messaging in OpenBazaar
- My personal suggestion is during the planning parts of phase 2, that we identify the minimal work required to deploy this feature to our users, and outline additional non-critical work we may want to do to enhance the system in a separate issue for future prioritisation
Requirements discussed in planning
Client
- Better name for "web relay" which disambiguates from existing IPNS circuit relay functionality.
- Send the message the fastest way possible while ensuring the mechanism doesn't break anything. One of two details enable this requirement:
- Order message application needs to be idempotent (more broadly than offline messages being deduplicated on receipt)
- Some assurance that keeps the potential for message duplicates isolated to offline messages (which can be mitigated by existing deduplication logic)
- Web relay only communicates with a single remote server to avoid the scope of sharing internal state across multiple app instances.
- Web relay usage is opt-out by the user via removal of configuration setting (There are privacy concerns to consider here.)
- If a recipient node is unavailable via web relay, the normal offline message path continues to work as before. (This may need to be provided by an affirmative NACK or error from the server to the client.)
- Ambiguity between OFFLINE (via DHT) and INDIRECT (via web relay) should be clear as part of the naming.
- The client needs to clearly indicate when it is failing to perform its normal function so managed failover can occur.
Server
- Web Relay is either stateless or must be a single instance (so that connection pools are not segreated by which server they are connected to).
- Highly-available deployment which allows the app to be renewed without manual intervention.
- Configurable exposed port for inbound connections