Data Sync
Transports

Configuring Transports

This article provides instructions on how to explicitly configure your Ditto instance to listen for connections on a specific port and to connect to remote instances using a host (IP) and port.

Although Ditto automatically attempts to connect to other instances on the Local Area Network (LAN), Bluetooth Low Energy (LE), and Apple Wireless Direct Link (AWDL), supplying a DittoTransportConfig does not enable this feature by default.

You must manually enable peer-to-peer connections using EnableAllPeerToPeer(). For instructions, see Enabling and Disabling Transports.

Configuring Additional Settings

In some cases, you may need to set up additional connection configurations for the current Ditto instance. This section provides instructions on how to explicitly configure your Ditto instance to listen for connections on a specific port and to connect to remote instances using a host (IP) and port.

To configure additional connection settings for the current Ditto instance, before calling startSync(), construct a DittoTransportConfig value and set it using ditto.SetTransportConfig.

Enabling and Disabling Transports



Swift
Kotlin
JS
Java
C#
C++
Rust


Syncing with Big Peer


Swift
Kotlin
JS
Java
C#
C++
Rust


Observing Peers​


Swift
Kotlin
JS
Java
Rust


pseudocode


Connecting to Remote Small Peers


Swift
Kotlin
JS
Java
C#
C++
Rust


Initializing LAN-Based WebSocket Connections

If syncing over LAN, ensure WebSocket connections are discoverable across peers within your local network:

Swift
Kotlin
JS
Java
C#
C++
Rust


Listening for Connections


Swift
Kotlin
JS
Java
C#
C++
Rust



Combining Multiple Transports


Swift
Kotlin
JS
Java
C#
C++
Rust


Monitoring Conditions


Swift
Kotlin
JS
Java
C#
C++
Rust