When you need this
Your game runs in a web browser, on a page served overhttps. Browsers block plain ws:// connections from an https page. They only allow wss://, the secure kind.
Turn on TLS for your port and Simpl handles the encryption. Your game server does not change.
If your game is not played in a browser, you don’t need this page.
Set it up
- Set your port to TCP. A new project starts with one UDP port. WebSocket needs TCP.
- Turn on TLS for that port. Open your project’s Environment tab, click Edit ports in the Ports section, and tick TLS on the port. Or click Browser / WebSocket game. It sets a TCP port named
gamewith TLS on, listening on 8080. You can change the number. Then click Save. - Listen on plain TCP in your game. Don’t add encryption to your server. Simpl does that. Read the port from
SIMPL_PORT_GAMEwhen your server starts, as described in Ports and environment.
tls_enabled to true on a TCP port. See Update a project.
How to connect
Players connect to:host and external_port from your server’s details. For example, wss://iad.servers.simpl.gg:31456. The server details in the dashboard show the full address. In the API, the same values are in network_ports.
Always use the host name. Never use the IP address. TLS only works with the host name.
What to expect
- A TLS port accepts
wss://only. A plainws://connection to it fails. - If you also need plain
ws://, for example to test on your own computer, add a second TCP port and leave TLS off on it. - Your game still sees plain TCP. It never sees the encryption.
- TLS works on TCP ports only. A UDP port with TLS on is refused with the error
TLS_REQUIRES_TCP.
If it does not connect
- The port is still UDP. Switch it to TCP, then turn on TLS.
- You used the IP address. Use the host name from the server’s details.
- The page is on
httpand the address isws://. A page onhttpscan only openwss://. Use thewss://address with the host name. - The server started before you saved the setting. Running servers keep the settings they started with. Start a new server.
- You tried
ws://on a TLS port. Usewss://, or add a second TCP port without TLS.
Example: Godot 4
This is only an example. It shows the least code that works. Other engines do the same two things: listen on plain TCP on the port Simpl gives you, and connect from the browser withwss://.
In your server, listen with WebSocketMultiplayerPeer. Read the port and address Simpl gives you. There is no TLS in your game.
wss:// and the host and port from the server’s details:
https page can only connect with wss://.