Connecting Nodes¶
Connecting two TruSpace installations allows them to sync documents, workspaces, metadata, and AI perspectives automatically via IPFS. Each organisation runs its own node; connecting them enables fault-tolerant, decentralised collaboration.
How It Works¶
When nodes are connected:
- The IPFS swarm establishes a peer-to-peer connection between nodes (port
4001) - The IPFS Cluster coordinates which content is pinned where (port
9096) - A shared cluster secret authenticates cluster membership
- A shared swarm key isolates the private network from the public IPFS network
- Documents and metadata replicate automatically once pinned
Required Ports¶
Open these ports on both nodes before connecting:
| Port | Protocol | Purpose |
|---|---|---|
4001 |
TCP + UDP | IPFS swarm (peer connections) |
9096 |
TCP | IPFS Cluster swarm |
Automatic Connection (Recommended)¶
TruSpace provides two scripts that handle the full connection setup.
Step 1 — On the Target Node: Generate Connection Details¶
Encrypted mode (recommended for secure transfer):
This creates two files:
- .connection — encrypted connection details (IP, IPFS peer ID, cluster peer ID, swarm key, cluster secret)
- .connection.password — the decryption password
Unencrypted mode (for trusted local networks only):
Creates only .connection (plaintext).
Step 2 — Transfer the Files¶
Securely transfer both .connection and .connection.password to the connecting node (e.g. via scp, encrypted email, or a password manager).
Step 3 — On Your Node: Run the Connection Script¶
Place the received files in the TruSpace root directory, then:
Encrypted mode:
Unencrypted mode:
The script will:
1. Decrypt and parse the connection details
2. Add the peer's IPFS address to Bootstrap in /volumes/ipfs0/config
3. Add the cluster peer address to peer_addresses in /volumes/cluster0/service.json
4. Copy the swarm key and cluster secret into place
5. Restart both the IPFS and cluster containers automatically
Manual Connection¶
For more control, use the manual script directly:
./scripts/connectPeer-manually.sh \
<peer_ip> \
<ipfs_peer_id> \
<cluster_peer_id> \
<ipfs_container_id> \
<cluster_container_id> \
[swarm_key_path] \
[cluster_secret_path]
Arguments:
| Argument | Description |
|---|---|
peer_ip |
IP address of the target node |
ipfs_peer_id |
libp2p Peer ID of the target IPFS node |
cluster_peer_id |
libp2p Peer ID of the target IPFS Cluster node |
ipfs_container_id |
Local IPFS container name (usually ipfs0) |
cluster_container_id |
Local cluster container name (usually cluster0) |
swarm_key_path |
(Optional) Path to swarm key file for private networking |
cluster_secret_path |
(Optional) Path to a file containing the cluster secret |
Example:
./scripts/connectPeer-manually.sh \
217.0.0.1 \
QmXabc...123 \
QmYdef...456 \
ipfs0 \
cluster0 \
./swarm.key \
./cluster_secret.txt
Getting Peer IDs from the Target Node¶
# IPFS Peer ID
docker exec ipfs0 ipfs id -f "<id>"
# Cluster Peer ID
docker exec cluster0 ipfs-cluster-ctl id
What the Scripts Configure¶
IPFS Network (/volumes/ipfs0/config)¶
Adds the peer's IPFS multiaddress to the Bootstrap section:
The swarm key (/volumes/ipfs0/swarm.key) isolates the network — only nodes with the same key can connect. It looks like:
IPFS Cluster (/volumes/cluster0/service.json)¶
Adds the peer's cluster multiaddress to peer_addresses:
The secret field must match the same value on all cluster peers.
Verifying the Connection¶
Check IPFS Peers¶
The target node's peer ID should appear in the list.
Check Cluster Peers¶
Check for Pinning Errors¶
All items should show PINNED. Any PIN_ERROR entries indicate replication problems — check connectivity and cluster secret consistency.
Practical Verification¶
Upload a document to a public workspace on one node. It should become visible on the other node within a few minutes.
Troubleshooting¶
Connection Refused¶
- Confirm port
4001and9096are open on both firewalls - Verify the peer IP is correct and reachable:
ping <peer_ip> - Check that both nodes are running:
docker ps
Cluster Not Syncing¶
- Confirm
CLUSTER_SECRETin.envis identical on all nodes - Check cluster logs:
docker logs cluster0 - Restart the cluster:
docker compose restart cluster0
Swarm Key Mismatch¶
All nodes in a private network must use the same swarm.key. If keys differ, IPFS nodes will refuse to connect.
For more diagnostics, see the Troubleshooting guide.