Installation

How to install and run Resgate

Install via Docker

If you install Docker, it is easy to run both NATS server and Resgate as containers:

docker network create res
docker run -d --name nats -p 4222:4222 --net res nats
docker run --name resgate -p 8080:8080 --net res resgateio/resgate --nats nats://nats:4222

Both images are small, less than 10 MB each.

Install release binary

Get the binary-zip file matching your architecture, either from the download page, or from the GitHub releases page.

Unzip the file. Inside the folder, there is a single command-line executable ready to run. That’s it!

Install from source

An alternative is to build the binaries yourself. First make sure you have installed Go.

Download and build Resgate using go install:

go install github.com/resgateio/resgate@latest

Running Resgate

Before starting Resgate, NATS Server must be installed and running. Don’t worry; installing NATS is just as easy.

To run Resgate with default settings:

resgate

When started successfully, it will connect to NATS on TCP port 4222 and output something like:

2006/01/02 15:04:05.786375 [INF] Starting resgate version 1.8.0
2006/01/02 15:04:05.869360 [INF] Connecting to NATS at nats://127.0.0.1:4222
2006/01/02 15:04:05.874344 [INF] Listening on http://0.0.0.0:8080
2006/01/02 15:04:05.875345 [INF] Server ready

Tip

If you get the following error:

Failed to connect to messaging system: nats: no servers available for connection

Then you either don’t have NATS server running, or Resgate is configured to connect to the wrong port.

For more options, read about Resgate configuration and usage.

Try out Resgate with one of the examples.

Note

In production environments, Resgate should be restarted on failure.

Resgate is designed to exit with an error code if something goes wrong, and will recover once restarted. This can be done by using Restart=on-failure in the systemd service configuration on Linux, or using the Docker restart policy, --restart on-failure.