# Epic Online Services (EOS) Relay

{% hint style="success" %}
Before you start setting up Epic Online Services, consider that the [coherence Cloud](https://docs.coherence.io/hosting/coherence-cloud) is\\

* [Free to start](https://coherence.io/pricing)
* Does not require the time-consuming process of setting up a relay
  {% endhint %}

Epic Online Services (EOS) is an open and modular set of online services for game development. In order to use EOS you will need to set up and configure your product with the Epic Games Store, Epic Tools and Epic Online Services. This is done through their [developer portal](https://dev.epicgames.com/docs/dev-portal). Once you have your product set up you'll be able to pass messages between clients via EOS servers.

To make things easy, **coherence** provides a complete EOS relay implementation that provides out-of-the-box networking over EOS. The EOS relay utilizes the [PlayEveryWare EOS Unity Plugin](https://github.com/EOS-Contrib/eos_plugin_for_unity) to access the EOS API.

{% hint style="info" %}
The EOS relay is available here: <https://github.com/coherence/eos-integration-sample>
{% endhint %}

<figure><img src="https://content.gitbook.com/content/CMCtKgV0bk1lwR4tWK3W/blobs/sUUiFYuVL9HmjGOoGrpG/image.png" alt=""><figcaption></figcaption></figure>

### Connecting over EOS, step-by-step

1. The host (Client A) starts a Replication Server on its local machine.
2. The host connects to the local Replication Server.
3. The host uses the EOS Dev Auth Tool to login to EOS services.
4. The host initializes an `EOSRelay` that listens for incoming EOS connections.
5. Another player (Client B) connects to the host via EOS after logging in using the EOS Dev Auth Tool and using the `EOSTransport`.
6. The `EOSRelay` accepts the incoming connection, creating a `EOSRelayConnection`.
7. The `EOSRelayConnection` immediately starts passing data between the EOS servers and the Replication Server.
8. The relayed connection is now fully established. All data between Client B and the Replication Server is relayed through EOS.
9. For each new Client that connects, steps 5-7 are repeated.

{% hint style="success" %}
Although the diagram above shows that traffic is routed via EOS servers, it is often the case that traffic can flow directly between player and host machines without actually making the extra hop via the EOS servers.

This technique is commonly referred to as "hole punching" or "**NAT Punch-through**". It reduces latency a lot. However, it is not supported on all networks due to firewall restrictions.

EOS's networking service will first attempt a NAT punch-through and then automatically fall back to relayed communication if the punch-through failed.
{% endhint %}
