JavaScript is required

EmulatorJS Netplay Server Setup Guide

Step-by-step instructions to set up your own EmulatorJS netplay server.

Prerequisites

Before beginning ensure you have a netplay server to use or host your own.

Server Setup

The EmulatorJS Netplay server is maintained in a separate repository.
Go clone the repository and follow its instructions:

git clone https://github.com/EmulatorJS/EmulatorJS-Netplay.git
cd EmulatorJS-Netplay

Follow the README in the repository for installation and running instructions.


Website Integration

In your JavaScript configuration file:

  1. Set a Unique Game ID
EJS_gameID = 1; // Must be unique per game on your website
  1. Configure Server Settings

Add or remove ICE servers as needed for your specific requirements. These are just examples of free, open-source servers.

EJS_netplayServer = 'https://yourIP:port#';
EJS_netplayICEServers = [
    { urls: 'stun:stun.l.google.com:19302' },
    { urls: 'stun:stun1.l.google.com:19302' },
    { urls: 'stun:stun2.l.google.com:19302' },
    { urls: 'stun:stun.nextcloud.com:3478' },
    { urls: 'turn:openrelay.metered.ca:80', username: 'openrelayproject', credential: 'openrelayproject' },
    { urls: 'turn:openrelay.metered.ca:443', username: 'openrelayproject', credential: 'openrelayproject' }
];

You can visit https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Protocols for more information on what these servers are used for.


Sharing Your Server

To allow friends to connect to your server over the internet, you need to configure your firewall and router.

Firewall Configuration

Windows

  1. Search for "Windows Defender Firewall with Advanced Security"
  2. Navigate to "Inbound Rules"
  3. Click "New Rule..."
  4. Select "Port" and follow prompts to allow TCP traffic for the port used by your server (default 3000)

Linux (using ufw)

sudo ufw allow 3000/tcp

Port Forwarding

  1. Find Your Local IP Address
    • Windows: Run ipconfig in Command Prompt, look for "IPv4 Address"
    • Linux: Run hostname -I in terminal
  2. Access Router Admin Panel
    • Open web browser and navigate to your router admin page
  3. Configure Port Forwarding
    • Create a rule with these settings:
      • Application Name: Netplay Server
      • External/Start Port: 3000
      • Internal/End Port: 3000
      • Protocol: TCP
      • Device IP: Your computer's local IP address

Share Connection Details

  1. Find Your Public IP
    • Google search: "what is my IP"
    • Copy the displayed IP address
  2. Give the Connection Details to Friends
    • Format: [Your Public IP]:3000
    • Example: 123.45.67.89:3000

Troubleshooting

  • Ensure Node.js is installed
  • Verify firewall rules are correctly configured
  • Check that port forwarding is set up on your router
  • Confirm your public IP address is current
  • Make sure the server is running before attempting connections