HiveMP netcode.io Auth Quickstart

How did we do?

This quickstart shows you how to configure a netcode.io game server with HiveMP netcode.io Auth and authenticate sessions to it.

Start the Docker container with the netcode.io game server

To test netcode.io authentication, you'll need a game server and client that implements netcode.io. We provide example Docker images that provide basic connectivity over netcode.io so you can test authentication.

Launch the example netcode.io server container on your local machine by running the following command:

docker run --rm -t --name netcode-server hivemp/docker-netcode-example:server-1.01 0.0.0.0:4000

In another window, run the following command to discover the IP address of the server in the Docker network:

docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' netcode-server

You should a receive an IP address similar to 172.17.0.6. Note this IP address down for later.

Create a netcode.io authentication entry for the game server

To authenticate with a netcode.io server, you need to provide HiveMP netcode.io Auth with the information required to generate connection tokens.

  1. Sign into the Admin Console.
  2. Click netcode.io Auth under the menu on the left-hand side.
  3. Click Create netcode.io Server Authentication.
  4. For Name, enter "Test Server".
  5. For Server protocol ID, enter 0x1122334455667788. This is the protocol ID used by the example Docker image previously launched.
  6. For Server private key, enter 60 6a be 6e c9 19 10 ea 9a 65 62 f6 6f 2b 30 e4 43 71 d6 2c d1 99 27 26 6b 3c 60 f4 b7 15 ab a1. This is the private key used by the example Docker image previously launched.
  7. For Server endpoints, click Add twice, then enter the following endpoints:
    • Address "IP ADDRESS", port "4000". Replace IP ADDRESS with the IP address of the Docker server container that you copied in the previous step.
    • Address "0.0.0.0", port "4000".
  8. For Token expiry seconds, enter "120".
  9. For Server timeout seconds, enter "120".
  10. For Userdata type, leave it as the default of "HiveMP Identity".
  11. Click Create and Remain.

Obtain a netcode.io connection token

To connect game clients to netcode.io-based game servers, you need to obtain a connection token from HiveMP netcode.io Auth. For testing purposes, you can obtain a connection token in the Admin Console.

  1. Sign into the Admin Console.
  2. Click netcode.io Auth under the menu on the left-hand side.
  3. Locate the "Test Server" authentication entry you previously created, and click Edit.
  4. Click Acquire Connection Token.
  5. Copy the base64-encoded connection token for use in the next step.

Start the Docker container with the netcode.io game client

With the netcode.io game server running and connection token acquired, you can connect the example game client to the game server.

Launch the example netcode.io client container on your local machine by running the following command. Replace BASE64_CONNECTION_TOKEN with the connection token you obtained:

docker run --rm -t --name netcode-client hivemp/docker-netcode-example:client-1.01 BASE64_CONNECTION_TOKEN

Observe the server and client communicating

Once you've run the client container, you should see text similar to the following in the client container's output:

[client_token]
client started on port 33242
client connecting to server 172.17.0.6:4000 [1/2]
client connected to server

In the server container, you should see text similar to the following in the server container's output:

[server]
server listening on 0.0.0.0:4000
server started with 256 client slots
server accepted client 172.17.0.7:33242 001445f1ec000000 in slot 0

If you see output above with connected to server and accepted client, then you've successfully connected a game server and client together with netcode.io authentication.

Further reading