Multiplayer Testing
Running your server locally and allowing friends or testers to connect to it is a great way to get feedback on your game or debug it with multiple players. You can quickly allow players to connect by using cloudflare's free tunneling service, cloudflared
.
1. Install cloudflared
First, install cloudflared on your the computer or server that will run your game server.
Follow this guide to install cloudflared.
2. Start your server without SSL
Local development by default uses SSL with a self-signed certificate, but a cloudflare tunnel will provision it's own SSL certificate. We need to disable the one our server uses to prevent conflicts.
We can do this and run our game at the same time by running the following command in our terminal. Setting NODE_ENV=production
will signal the server to not use it's own SSL certificate.
If you're using a Mac or Linux terminal, run the following command.
# Start our game server without SSL
NODE_ENV=production bun --watch index.ts
If you are using Windows Powershell, use the following command:
# Start our game server without SSL using Windows Powershell
$env:NODE_ENV="production"; bun --watch index.ts
3. Start a tunnel
Next, open another terminal window and run the following command to start your cloudflared tunnel. This assumes your game is running on the default port, which is 8080.
# Start our tunnel!
cloudflared tunnel --url http://localhost:8080
Once started, you should see something like this:
4. Share your tunnel link & play
Copy your tunnel link from your terminal. Your tunnel link will be different, but for context, in our previous example our example link was:
https://sie-perception-directories-currency.trycloudflare.com
Your tunnel link will be different each time you start your tunnel!
You and others can now connect to your server by going to https://hytopia.com/play and entering your tunnel link when prompted to enter a server to connect to.
You can alternatively make players auto-join your server with a link by using the ?join=
query parameter like this:
https://hytopia.com/play?join=sie-perception-directories-currency.trycloudflare.com
Just make sure you replace the value of join
with your own tunnel url!
Next Steps
Last updated