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:
- Set a Unique Game ID
EJS_gameID = 1; // Must be unique per game on your website
- 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
- Search for "Windows Defender Firewall with Advanced Security"
- Navigate to "Inbound Rules"
- Click "New Rule..."
- 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
- Find Your Local IP Address
- Windows: Run
ipconfig
in Command Prompt, look for "IPv4 Address" - Linux: Run
hostname -I
in terminal
- Windows: Run
- Access Router Admin Panel
- Open web browser and navigate to your router admin page
- 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
- Create a rule with these settings:
Share Connection Details
- Find Your Public IP
- Google search: "what is my IP"
- Copy the displayed IP address
- Give the Connection Details to Friends
- Format:
[Your Public IP]:3000
- Example:
123.45.67.89:3000
- Format:
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