Skip to content

Install Pitaya with Go, Docker, and Localtonet

Install and verify the Pitaya game server framework, run its cluster example with Docker, then provide remote connector access through a TCP tunnel.

Summary in your language
In this article 9 sections
Game Server Tutorials · Pitaya · Localtonet · 2026

Build a working Pitaya cluster, test its TCP connector, and reach it from another network

Pitaya is a Go framework for distributed multiplayer game servers and other server-side applications. This guide installs Pitaya from its official repository, starts the cluster_grpc example with etcd, runs the frontend connector and backend room services, installs the official Pitaya CLI, and verifies the application route on port 3250. After the complete request works locally, we create a Localtonet TCP tunnel and repeat the same test through its assigned public host and port. The instructions distinguish the moving default branch from a reproducible v2.11.24 checkout and explain the Docker Compose command difference you may encounter.

🔒 Verify the application before exposing it 🌐 Forward only the TCP connector ⚡ Test the full connector-to-room route
Pitaya installation, Docker cluster, and TCP tunnel workflow.
The workflow progresses from a local Pitaya installation to a verified cluster and then to controlled remote TCP access.

What this Pitaya setup contains

Pitaya is a scalable game-server framework with clustering support and client libraries for platforms including iOS, Android, and Unity through its C SDK. This tutorial uses the repository's cluster_grpc example because it provides a compact way to verify several important layers: a client-facing connector, an internal room service, service discovery through etcd, and a routed application request.

The frontend connector is the only client-facing Pitaya service in this workflow. The official command-line example connects to localhost:3250 and requests room.room.entry. The connector passes that route into the cluster, the room handles it, and the result returns through the connector. Receiving {"code":0,"result":"ok"} therefore proves more than seeing a process remain open.

The selected connector uses a TCP listener on port 3250. That concrete connector configuration is why this guide uses a Localtonet TCP tunnel. gRPC is used between server components in the cluster example, but that does not mean the remote player or CLI connection should be sent directly to a backend gRPC service. The public target remains the connector's TCP listener.

🎮 Frontend connector Accepts the example client's TCP connection on port 3250 and acts as the controlled client-facing entry point.
🏠 Backend room Handles the documented room.room.entry route and returns the successful result used for verification.
🧭 etcd discovery Supports service discovery in this clustered example and runs through the example's Docker Compose configuration.
🌐 Localtonet TCP tunnel Maps an assigned public host and port to the connector address reachable from the selected Localtonet device.

Local verification comes first

Treat application setup and public reachability as separate milestones. First verify Go, Pitaya's setup target, etcd, the connector, the room process, and the local CLI request. Only after that request succeeds should you add a tunnel.

This order creates a useful fault boundary. If room.room.entry fails on localhost:3250, the problem belongs to the application stack or its dependencies. If the local request succeeds but the same request fails through the public endpoint, investigate the Localtonet device, tunnel state, target address, assigned endpoint, or remote client.

Keep the two traffic paths distinct

The example uses gRPC for communication inside the Pitaya cluster, while the tested client-facing connector listens for a TCP client on port 3250. Configure the Localtonet tunnel for the client-facing TCP connector, not for etcd, the room process, or an internal gRPC endpoint.

Prerequisites for the Pitaya cluster example

The Pitaya README states a minimum of Go 1.16. A particular branch or release can impose additional requirements through its current go.mod, dependency graph, build tooling, or example files, so the checked-out revision remains authoritative. Do not assume that an old Go installation is suitable merely because it satisfies the historical minimum.

You also need Git, Make, Docker Engine, Docker Compose, and the official Pitaya CLI. Pitaya lists etcd, NATS, and Docker as optional dependencies in the general project description. For this particular example, etcd and Docker Compose are part of the documented startup path. NATS is not part of the commands below.

Requirement Purpose in this tutorial Verification
Go Builds Pitaya and installs pitaya-cli go version
Git Clones the official repositories git --version
Make Runs the setup, server, and test targets make --version
Docker Engine Runs the example's etcd container docker --version
Docker Compose Starts and inspects the named etcd service docker compose version or docker-compose version
Pitaya CLI Connects to the connector and sends the application request pitaya-cli
Localtonet client Creates the outbound connection used for remote forwarding Device appears connected in the current dashboard

Check the local tools

go version
git --version
make --version
docker --version
docker compose version

If the final command is unavailable, check whether your environment has the legacy standalone Compose executable:

docker-compose version

Docker Compose V1 used the hyphenated docker-compose executable. Compose V2 integrates Compose into the Docker CLI and uses docker compose. Docker explains the command transition in its Compose V1 to V2 migration documentation.

The Pitaya example instructions use the legacy docker-compose spelling. The equivalent V2 form is docker compose. Use the form installed on your machine, but do not combine both forms in one command.

Do not expose cluster dependencies

The intended public target is the frontend connector. Keep etcd and backend services private. A tunnel aimed at the wrong local port can unintentionally publish service-discovery or internal application infrastructure.

Install Pitaya and the official Pitaya CLI

Choose a moving or reproducible checkout

Cloning without a tag checks out the repository's default branch at that moment. This is useful when evaluating the newest project state, but it is not reproducible because later commits can change the Makefile, dependencies, examples, or configuration.

git clone https://github.com/topfreegames/pitaya.git
cd pitaya
make setup

For a repeatable evaluation, select a release and record it with your environment. GitHub marked Pitaya v2.11.24 as the latest release when checked on August 20, 2026. Clone that tag directly with:

git clone --branch v2.11.24 --depth 1 https://github.com/topfreegames/pitaya.git
cd pitaya
make setup

This tutorial uses the commands and example layout associated with that selected workflow. Commands observed on the current default branch should not automatically be assumed to apply to every older tag. If you select another release, inspect its README, Makefile, go.mod, and examples directory before running the commands.

1

Clone the selected Pitaya revision

Use the default-branch command for current development work or the tagged command for a reproducible v2.11.24 checkout.

2

Enter the repository root

Change into pitaya. The setup, connector, room, and test Make targets run from this directory.

3

Run the setup target

Run make setup and resolve any reported error before starting the example.

Install pitaya-cli

The official client is maintained in the topfreegames/pitaya-cli repository. With a current Go toolchain, install its command from the official module:

go install github.com/topfreegames/pitaya-cli@latest

Go normally writes installed commands to GOBIN when that variable is configured, or to the bin directory under GOPATH otherwise. Check the resolved location with:

go env GOBIN
go env GOPATH

If the installation succeeds but your shell reports pitaya-cli: command not found, add the applicable Go binary directory to your shell's PATH, open a new terminal, and run:

pitaya-cli

The @latest selector follows the latest version resolved by Go and is convenient for development. For a controlled environment, record the exact CLI module version resolved during installation and validate it with the Pitaya server release you selected.

What v2.11.24 changed

The v2.11.24 release fixes a shutdown race in the NATS connection handler that could send to a closed channel when NATS became unavailable while a server was terminating. The panic could interrupt graceful shutdown and leave an etcd discovery entry until its lease expired. This example does not start NATS, but the fix remains relevant when evaluating that release for a NATS-enabled deployment.

Run the cluster_grpc example

Docker topology with a Pitaya connector linked to a room over gRPC.
The example separates the client-facing connector from room handling and uses gRPC between clustered Pitaya services.

The example needs three running components: etcd, the connector, and the room. Start etcd from examples/testing. Start each Pitaya server from the repository root in its own terminal because both processes remain active while serving requests.

1

Start the etcd service

Enter examples/testing and start the Compose service named etcd in detached mode.

2

Start the frontend connector

In a second terminal at the Pitaya repository root, run the connector Make target and leave it active.

3

Start the backend room

In a third terminal at the repository root, run the room Make target and leave it active.

Terminal 1: start etcd

The repository documentation uses the legacy Compose command:

cd pitaya/examples/testing
docker-compose up -d etcd

If you installed Docker Compose V2 rather than the standalone V1 executable, use its equivalent command from the same directory:

cd pitaya/examples/testing
docker compose up -d etcd

Run only one of these startup forms. Inspect the named service with the syntax supported by your installation:

docker compose ps etcd
docker compose logs etcd

For Compose V1, replace docker compose with docker-compose. Do not continue if etcd repeatedly exits or reports an unrecoverable startup error.

Terminal 2: start the connector

cd pitaya
make run-cluster-grpc-example-connector

If your terminal opens in a different parent directory, adjust the first command so that the Make target runs from the Pitaya repository root. Keep the process open and review its startup output for build, discovery, or listener errors.

Terminal 3: start the room

cd pitaya
make run-cluster-grpc-example-room

This target also runs from the repository root. The expected state is one active connector, one active room server, and the etcd service running through Docker Compose.

A running process is not a complete health check

The connector can remain open while the room is unavailable, discovery is incomplete, or the application route fails. Use the Pitaya CLI request in the next section as the readiness gate.

Verify the connector and room locally

Open a fourth terminal after all three cluster components are active. The Pitaya CLI accepts interactive commands in its REPL. Connect to the frontend at localhost:3250, then request the room route.

1

Launch the REPL

Run pitaya-cli in a separate terminal.

2

Connect to the local connector

Enter connect localhost:3250 at the CLI prompt.

3

Request the room route

Enter request room.room.entry and verify that the response reports code 0 and result ok.

pitaya-cli
connect localhost:3250
request room.room.entry

The successful interaction should include:

connected!
sv-> {"code":0,"result":"ok"}

These outputs represent two different checks. connected! confirms that the CLI established a connection to the frontend connector. The JSON response confirms that the named application request reached the room service and returned through the cluster.

Run the repository tests

make test

Run this target from the Pitaya repository root. Repository tests and a live example request complement each other. Passing tests do not prove that your running connector, room, and etcd instance are configured correctly. A successful example request also does not justify ignoring a failing unit or end-to-end test.

Check What it proves What remains unproven
Connector remains active The frontend did not immediately terminate Client connectivity and backend routing
connect localhost:3250 The local CLI reaches the connector The room route works
request room.room.entry The documented route returns through the cluster Every route and production workload
make test The checked-out repository's test target completes Public reachability through a tunnel

Provide remote connector access with Localtonet

Remote client reaching a local Pitaya connector through a Localtonet TCP tunnel.
The TCP tunnel forwards the assigned public endpoint to the verified Pitaya connector.

Once the local application request succeeds, create a Localtonet TCP tunnel to the connector. Our client establishes an outbound connection to a Localtonet relay, so this workflow does not require inbound router port forwarding, a public IP address, VPN setup, or an inbound firewall change for the public endpoint.

Install the Localtonet client on the Pitaya host or on another device that can reach the connector. For a client running on the same machine as this example, the target is the loopback address and port 3250. If the Localtonet client runs elsewhere, localhost refers to that other device. You must instead use a deliberately configured address that the Localtonet device can reach.

1

Install and run the Localtonet client

Use a supported client from the Localtonet documentation on the Pitaya host or another device with network access to the connector.

2

Authenticate the correct device

Use that device's authentication token. Tokens identify Localtonet client devices and must not be published or committed to source control.

3

Select an available relay server

Choose a currently available server or region from the dashboard. Do not copy a server code from another account or an old tutorial.

4

Create a TCP tunnel

Point its local target to the connector's reachable address and port 3250. For a same-machine installation, use the local loopback target. Do not target etcd or the room service.

5

Start the tunnel

Creating a tunnel does not start it. Use the Start action and note the assigned public host and public port.

6

Test and close access when finished

Repeat the application request from another network. Stop the tunnel when temporary access is no longer required, or delete an obsolete configuration.

Test the exact public endpoint with pitaya-cli

Run pitaya-cli from a device on another network. At its prompt, use the same supported connect host:port syntax as the local test, replacing the placeholders with the host and port displayed for your active tunnel:

pitaya-cli
connect <PUBLIC_HOST>:<PUBLIC_PORT>
request room.room.entry

For example, if the dashboard displays a host named assigned-host.example and public port 45000, the syntax would be connect assigned-host.example:45000. That hostname is illustrative only. Always use the endpoint actually assigned to your tunnel.

Do not replace the assigned public port with 3250 unless the dashboard itself assigns that value. Port 3250 remains the local connector target behind the tunnel. The remote client must use the public port shown by Localtonet.

A successful remote verification should again produce both a connection confirmation and the room response:

connected!
sv-> {"code":0,"result":"ok"}

That result demonstrates the complete path: the remote CLI reached the public endpoint, the tunnel forwarded the TCP stream to the local connector, and Pitaya routed the application request to the room.

Tunnel state is independent from Pitaya state

The selected Localtonet device must remain connected and the tunnel must remain started. A healthy connector is not remotely reachable through a stopped tunnel, while a running tunnel cannot make a stopped or unhealthy connector work.

Secure the public game connector

Security boundary exposing the connector while keeping the room service private.
Publish only the deliberately client-facing connector while keeping discovery and backend services private.

A TCP tunnel provides reachability. It does not define Pitaya player authentication, message authorization, application encryption, session policy, or abuse controls. Once started, the public host and port can receive connection attempts from the internet. Treat every remote connection as untrusted.

The example's successful room route is a functional test, not evidence that the example is production hardened. Before broad deployment, your application should authenticate clients, authorize routes and state changes, validate every message, reject malformed input, constrain resource use, and log security-relevant events. Test those controls with the actual client protocol and game behavior.

🔑 Protect device tokens Keep Localtonet authentication tokens out of repositories, screenshots, game binaries, logs, and public support messages.
🛡️ Authorize application actions Validate identity, session state, route access, message structure, and permissions inside the application.
🎯 Expose only the connector Keep etcd, backend room services, and internal gRPC communication outside the public tunnel.
⏹️ Limit exposure time Stop temporary tunnels after testing and delete configurations that no longer serve an operational purpose.
TCP forwarding is not an application security protocol

Do not infer end-to-end message confidentiality or player authentication merely because traffic passes through a TCP tunnel. Those properties depend on the protocol and controls implemented between your Pitaya client and connector.

Development workflow versus production deployment

This setup is well suited to development, remote integration testing, demonstrations, and controlled reviews. A production multiplayer environment requires additional decisions about process supervision, release pinning, configuration management, dependency availability, observability, capacity, graceful shutdown, authentication, abuse handling, backups where applicable, and deployment rollback.

Record the exact Pitaya commit or release, Go version, CLI version, Docker version, Compose version, and Localtonet client version used by each environment. Test normal shutdown and dependency-failure behavior before deploying long-lived services. The shutdown race fixed in v2.11.24 is an example of why operational release notes matter even when the feature set appears unchanged.

Operate and troubleshoot the stack layer by layer

Recommended startup and shutdown order

Start etcd first, followed by the connector and room. Perform the complete local CLI request before starting the Localtonet tunnel. This ordering proves each dependency before adding the next network layer.

During shutdown, stop the public tunnel first to prevent new remote connections. Then stop the Pitaya processes through their normal terminal interruption and shutdown path. Stop etcd last, after no running example service needs discovery.

From examples/testing, stop etcd with the command form provided by your Compose installation:

docker compose stop etcd

Compose V1 users should use:

docker-compose stop etcd

The repository clone fails

Confirm that Git is installed, the destination is writable, and the machine can reach the official repository. If Git created a partial pitaya directory, inspect or remove that incomplete checkout before retrying. Do not run setup commands from an uncertain working tree.

make setup fails

Verify go version, then read the first meaningful Make error. Confirm that you are in the repository root and that the selected revision's go.mod is compatible with your installed toolchain. Later error lines are often consequences of the first failed download, build, or generated dependency.

Docker Compose is not found

Try both version checks:

docker compose version
docker-compose version

Use the syntax that succeeds. If neither succeeds, install a currently supported Docker Compose implementation for your operating system. Having Docker Engine alone does not guarantee that a Compose command is installed.

etcd starts and then exits

Run the following from examples/testing, substituting the hyphenated command if you use Compose V1:

docker compose ps etcd
docker compose logs etcd

Diagnose the reported container error instead of continuing. The cluster example depends on its discovery layer. Starting a public tunnel will not repair an etcd startup failure.

A Make target is not found

The connector and room targets run from the Pitaya repository root:

make run-cluster-grpc-example-connector
make run-cluster-grpc-example-room

If the terminal is still in examples/testing, return to the root first. Also confirm that the selected revision contains those target names. Instructions from the default branch may not match an unrelated or substantially older tag.

pitaya-cli is not found

Repeat the official Go installation command and check the Go binary directories:

go install github.com/topfreegames/pitaya-cli@latest
go env GOBIN
go env GOPATH

If GOBIN is empty, the command is normally placed under the bin directory of the reported GOPATH. Add that directory to PATH and reopen the terminal.

The CLI cannot connect to localhost:3250

Confirm that the connector process remains active and has not reported a startup error. The CLI must run on the Pitaya host when localhost is used. A CLI inside another container, virtual machine, or computer has a different loopback interface.

Make sure you started the connector target rather than only the room. Port 3250 applies to this selected example configuration and should not be assumed for every Pitaya application.

The connection succeeds but the room request fails

A successful connection followed by a failed room.room.entry request indicates that the frontend is reachable but the route or backend cluster path is unhealthy. Confirm that the room process remains active, inspect both Pitaya terminals, and verify that etcd is still healthy. Restarting the tunnel cannot correct a request that already fails locally.

Local verification works but remote verification fails

  • Repeat request room.room.entry against localhost:3250.
  • Confirm that the intended Localtonet device is connected.
  • Confirm that the TCP tunnel is started, not merely saved.
  • Confirm that its local target reaches the connector on port 3250.
  • Use the assigned public host and assigned public port in connect host:port.
  • Run the test from a genuinely separate network when validating external access.
  • Inspect the connector output while making the remote attempt.

A common topology error occurs when Localtonet runs on a different device but the tunnel target remains localhost. In that case, loopback refers to the Localtonet device rather than the Pitaya host.

The public connection works but the request is incorrect

Basic TCP reachability probably exists. Compare the remote route and payload with the known-good local request, confirm client compatibility, and inspect the application logs. A TCP tunnel forwards a byte stream without translating an incompatible client protocol into Pitaya's protocol.

The tunnel stops unexpectedly

Verify that the Localtonet client process is running, the selected device remains connected, and the tunnel remains in its started state. Check Pitaya independently. A connected tunnel cannot deliver a useful request to a stopped connector, and a healthy connector is not remotely reachable through a stopped tunnel.

Use the layer-by-layer rule

Diagnose dependencies first, then Pitaya processes, local connection, local route request, Localtonet device connection, tunnel state, public connection, and finally the remote route request. This sequence identifies the first failing boundary instead of mixing application and tunnel symptoms.

Frequently asked questions

What version of Go does Pitaya require?

The Pitaya README states Go 1.16 or newer. The selected revision's current go.mod and dependencies can require a newer toolchain, so check them and record the Go version used by your build.

Should I use the default branch or v2.11.24?

Use the default branch when you deliberately want the newest repository state. Use a tested tag such as v2.11.24 when you need a reproducible source baseline. GitHub marked v2.11.24 as the latest release when checked on August 20, 2026, but release status can change.

Should I run docker-compose or docker compose?

The Pitaya example documentation uses the legacy docker-compose form. Docker Compose V2 uses docker compose. Both forms express the same example operation here, but you must use the command installed in your environment.

Are Docker, etcd, and NATS all required?

They are optional for Pitaya in general. The cluster_grpc workflow covered here uses etcd and starts it with Docker Compose. NATS is not part of the startup commands in this tutorial.

Why does this guide use a TCP tunnel?

The selected connector accepts the Pitaya CLI's TCP connection on port 3250. A Localtonet TCP tunnel therefore matches that client-facing transport. The gRPC communication between cluster services remains internal.

What exact command tests the public endpoint?

Start pitaya-cli, enter connect <PUBLIC_HOST>:<PUBLIC_PORT>, and then enter request room.room.entry. Replace both placeholders with the host and port assigned to the active Localtonet TCP tunnel.

Does creating a Localtonet tunnel start it?

No. Creating and starting are separate lifecycle actions. The selected client device must be connected, and the tunnel must be started before its public endpoint can forward traffic.

Does the TCP tunnel authenticate Pitaya players?

No. Your application must authenticate players, authorize routes and state changes, validate messages, and implement the security properties required by its protocol. The tunnel provides reachability to the configured TCP target.

Can the Localtonet client run on another machine?

Yes, if that device can reach the connector. In that topology, do not target localhost unless Pitaya runs on the same device. Use an intentionally configured reachable address and verify the connector's listener and local network policy.

Make your verified Pitaya connector remotely reachable

After the local CLI receives the successful room response, connect the device that can reach Pitaya and start a Localtonet TCP tunnel to the verified connector target. Keep etcd and backend services private, test with the assigned public host and port, and stop the tunnel when remote access is no longer needed.

Get Started Free →

Corrections & updates

Substantive changes approved by the Localtonet editorial team are listed transparently below.

Reviewed and updated for accuracy and completeness.

Localtonet is a secure multi-protocol tunneling and proxy platform designed to expose localhost, devices, private services, and AI agents to the public internet supporting HTTP/HTTPS tunnels, TCP/UDP forwarding, mobile proxy infrastructure, file server publishing, latency-optimized game connectivity, and developer-ready AI agent endpoint exposure from a single unified control plane.

Support