> For the complete documentation index, see [llms.txt](https://docs.origintrail.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.origintrail.io/operate/relays-and-peers.md).

# Relays & Peers

Nodes use libp2p for peer connectivity. Edge nodes behind NAT reserve relay slots so other nodes can reach them. The default network relay set is loaded from the active network config.

## How an Edge Uses Its Relays

* The relay list is `relay` from the node config (one relay), or else `relays` from the active network config. Operator-preferred relays are placed in front. `"relay": "none"` turns relays off.
* An edge keeps a connection to every relay in its list and holds reservations on three of them (`relayReservationCount`, 1 to 16).
* A node reserves only on relays in its list, and relayed connections to other nodes go through those relays only.
* Every Core node runs a relay server. An edge uses a Core as a relay when that Core is in the edge's list.

## Inspect Peers

```bash
dkg peers
dkg peer info <peer-id>
```

If peer discovery looks empty:

* confirm the daemon is running
* wait for discovery to settle
* check configured relays in node config
* inspect daemon logs
* verify that both nodes subscribe to the same Context Graph when expecting shared memory

Direct messages and query-remote are best-effort P2P operations. Treat timeouts as connectivity facts, not as proof that the remote data does not exist.

## Prefer Operator Relays

Use `--relay-preferred` when you run relays you control and want this node to try those relays before the network defaults:

```bash
dkg start \
  --relay-preferred /ip4/203.0.113.10/tcp/4001/p2p/12D3KooWMyRelayOne... \
  --relay-preferred /dns4/relay.example.com/tcp/4001/p2p/12D3KooWMyRelayTwo...
```

The flag is repeatable. Entries are prepended in CLI order for that daemon run. To persist the preference, set `preferredRelays` in `~/.dkg/config.json`:

```json
{
  "preferredRelays": [
    "/ip4/203.0.113.10/tcp/4001/p2p/12D3KooWMyRelayOne...",
    "/dns4/relay.example.com/tcp/4001/p2p/12D3KooWMyRelayTwo..."
  ]
}
```

CLI entries and config entries are deduplicated before they are prepended to the network relay list. Public relays stay as fallback.

## Messenger Health

Short peer-to-peer protocols that use Universal Messenger expose delivery latency and queued counts through the daemon API:

```bash
curl -H "Authorization: Bearer $(dkg auth show)" \
  http://127.0.0.1:9200/api/slo
```

Use this when peer commands show a reachable peer but messages still queue or feel slow. `/api/slo` is an in-memory snapshot; daemon restart resets its samples, while the underlying retry outbox survives restart.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.origintrail.io/operate/relays-and-peers.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
