Transports
DeRec does not define a network stack. Every protocol message travels as one serialized DeRecMessage envelope, and how those bytes get from one participant to another is the application's job. This section describes the delivery model every transport follows, then the two bindings the wire schema names:
HTTPS binding — recommended HTTP conventions for
Protocol.HTTPSendpointsgRPC binding — the
DeRecTransportservice forProtocol.GRPCendpointsPeers that cannot be reached — answering a phone, browser tab or CLI on the connection its request arrived on
The library opens no sockets
The reference library (derec-library and every SDK built on it) never dials, listens or polls. The application supplies one outbound callback, DeRecTransport::send(endpoints, message), and feeds every inbound envelope to protocol.process(bytes):
Outbound
The library calls the application's send
endpoints: the peer's advertised endpoints; message: one serialized DeRecMessage
Inbound
The application's server receives bytes and calls process
The raw envelope bytes, exactly as received
send is the same callback in every SDK: DeRecTransport::send (Rust), ITransport (.NET), protocol.Transport.Send (Go), Transport.send (Node.js / Web / React Native).
Delivery is push: a mailbox, not a phone call
Every participant has an address, and answering someone means posting to their address. There is no notion of "the connection this message arrived on":
A response produced while processing an inbound message is not returned to the caller of
process. It is handed tosend, addressed to the peer's endpoints — the entries of the request'sreplyToTransportsthat pass this device's transport policy, when any do, otherwise the endpoints the peer advertised assupportedTransportsat pairing time or later throughUpdateChannelInfo.processreturns onlyDeRecEvents describing what happened (ShareStored,PairingCompleted,ActionRequired, …). Its return value never contains wire bytes.start,acceptandrejectdeliver whatever they produce through the same callback.
The request/response pairing in the wire schema is per message type — StoreShareRequestMessage has a matching StoreShareResponseMessage, and the response echoes the request's traceId — not per network round trip. Both deliveries are separate pushes, and a pushed response needs no matching: its receiver passes it to process. Matching a reply by traceId applies only when the reply rides back as the 200 OK answer on the request's own connection — see Peers that cannot be reached.
Every participant needs a reachable endpoint
Because responses are pushed, both parties must run an endpoint the other can reach — Owners included. Messages also arrive without a request from the receiver: a Helper sends UpdateChannelInfoRequestMessage to its Owner when its own endpoints change, a replica source pushes every Secret update to the replica destinations, and admitting a new Helper republishes shares to the Helpers already paired. A participant that advertises an endpoint nothing can reach (a phone, a browser tab, a CLI, anything behind NAT) pairs successfully and then never hears back; nothing errors. See Peers that cannot be reached for the supported workaround.
Advertised endpoints
Each participant advertises all of its own endpoints, in its own preference order, at most one per protocol: as supportedTransports on ContactMessage, PairRequestMessage and PrePairRequestMessage, and later on UpdateChannelInfoRequestMessage. The list is set with with_own_transports (WithOwnTransports in .NET, withOwnTransports in Node.js / Web / React Native, Config.OwnTransports in Go) and changed at run time with set_own_transports.
Rules that follow from push delivery:
List only what you serve. Every entry must be an endpoint this device actually listens on. Listing one it does not makes pairing succeed and responses vanish.
The receiver records, it does not choose. The receiver filters the peer's list through structural validation and its plaintext policy, drops a repeated protocol (the first entry wins), and records every survivor in the peer's order. No entry surviving is
Error::NoUsableEndpoint; at pairing time this is terminal, because a peer that cannot be reached cannot be sent a rejection either.sendreceives the whole list. The library ranks nothing. The application's transport picks the endpoint to dial and whether to fall back.
Accepted schemes, size limits and the plaintext policy are in Dev environment setup → Transport endpoints and plaintext connections and Messages → TransportProtocol.
Implementing send: deliver once, fail over in order
Delivery to any one endpoint is success; send returns an error only when the message reached none of them. Every entry addresses the same peer, so delivering to all of them sends one authenticated message several times — stop at the first success.
That bookkeeping is the same in every application, so each SDK ships it. Implement SendOne — deliver one message to one endpoint — and wrap it:
SequentialFailover
Tries each endpoint in the peer's order and returns at the first success. Fails only when every endpoint failed.
SingleEndpointTransport
Uses only the first endpoint. Use it when giving up failover is intended, so the choice is visible to a reader.
The SDK names are ISendOne + SequentialFailover (.NET), protocol.SendOne + protocol.SequentialFailover (Go), and SendOne + sequentialFailover / singleEndpointTransport (Node.js / Web / React Native).
An error returned by send propagates out of the library call that triggered it. On fan-out flows started with start, a failing target is reported as a per-channel *Failed event and does not stop delivery to the other targets.
What the protocol does not specify
The protocol fixes the envelope bytes and the push model. It does not fix HTTP methods, headers, status codes, gRPC status codes, body-size limits or timeouts. The HTTPS binding page records the recommended conventions for interoperability.
Last updated