> For the complete documentation index, see [llms.txt](https://docs.reya.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.reya.xyz/developers/devnet/connectivity/connecting-to-the-matching-engine.md).

# Connecting to the Matching Engine

How order flow reaches Reya's matching engine (ME), and the recommended connection setup for integrators.

## Where the matching engine is

Reya's infrastructure — including the matching engine — runs in **Google Cloud `europe-west3` (Frankfurt)**. Plan your own placement with that region in mind to minimise round-trip latency.

## How you connect

* Orders reach the ME **over the public internet** via the published REST and WebSocket endpoints (see [Environments](/developers/devnet/getting-started/environments.md)).
* You can connect over **REST** or **WebSocket**. **WebSocket is recommended for most integrations**: a persistent connection with lower per-operation overhead and id-correlated responses.

## Recommended setup: two WebSocket connections

Run both surfaces in parallel:

* [**WebSocket Order Entry**](/developers/devnet/api-reference/ws-exec-api-reference.md) — placing and cancelling orders (the write side).
* [**WebSocket Info**](/developers/devnet/api-reference/websocket-api-reference.md) — depth, order changes, executions, and balances (the read side).

## Cancel-on-Disconnect (COD)

Cancel-on-Disconnect is an **account-scoped dead-man's switch**: you arm a countdown and refresh it on your own heartbeat, and if you stop refreshing it the matching engine cancels your open orders — **except protective stops** (`STOP_LOSS` / `TAKE_PROFIT`), which it leaves in place. It is **not** triggered by a WebSocket close: closing the socket neither fires nor disarms the timer, and only another `cancelAllAfter` refreshes it.

See [Cancel-on-Disconnect](/developers/devnet/order-entry/cancel-on-disconnect.md) for bounds, mechanics, and error codes.

## Staying connected

Connection liveness is handled by standard protocol-level pings — see [Heartbeats](/developers/devnet/connectivity/heartbeats.md). On reconnect, re-subscribe to your channels and reconcile any missed state from REST (see the reconnection guidance in the [WebSocket Info API Reference](/developers/devnet/api-reference/websocket-api-reference.md)).
