openOMSI GitHub Discord

Docs / Multiplayer

Dedicated server

Run a whole map without a window: configuration, uploads, administration, bans, the public list.

34 min readEdit this pagedocs/SERVER.md

shell
openomsi --root /path/to/OMSI2 --server /opt/openomsi-server/server.cfg

Every release has ready server packages: openOMSI-<version>-server-linux-x64.zip and -server-linux-arm64.zip (started with start.sh /path/to/OMSI2 [server.cfg]), and for Windows 10/11 and Windows Server 2016 or later -server-windows-x64.zip and -server-windows-arm64.zip (started with start.cmd C:\path\to\OMSI2 [server.cfg]).

scripts/build-server.sh [folder] builds the same on a Linux machine into dist/server. The OMSI 2 folder given is a complete original installation, as the players have it; the server's mods go into its Vehicles, maps, Sceneryobjects … as in the game's content folder.

The server is the game binary hosting a session with no window, no sound and no graphics card: the renderer runs on wgpu's no-op device, so the world, the AI traffic, the timetable buses and the people are simulated exactly as a hosting player's game does, and nothing is drawn. server.cfg is written with a comment for every key on the first start:

Keys What they set
name, motd shown in the players' server list and when they join
map, date, time, weather the map, the start date (empty: today), the time of day, the weather (a .owt, empty: the map's default, cycle: one after another through the day)
speed_limit_kmh Optional RP speed limit: 0 (off), 60, 75, or 80 km/h
time_speed, real_time how fast the clock runs (1 to 30), or the machine's real date and time
metar_sync, metar_station the weather follows an airport's METAR report (ICAO code; empty: the one nearest the map), downloaded every ten minutes and passed on to the players
traffic, timetable, passengers, passenger_density AI cars, timetable buses, waiting passengers and how many of them (below)
ai_drive_through_parked 1: the AI drives on through a parked car standing in its lane, as OMSI 2's does, instead of stopping behind it and going round it when it can (for maps where a parked car stands in the lane with no way round); 0 (default) keeps the stop
ai_unsched_factor, ai_max_scheduled, ai_max_parked, ai_max_humans the server's own AI limits, for the whole server: random traffic in percent of the map's density (0 to 300), timetable vehicles at once (0: no limit), parked cars (0: every space, -1: none), people at once (1 to 4096, not per player); empty: the values of settings.cfg
port, web_port, max_players UDP port of the session (27015), TCP port of the web gateway (27025), player limit (16)
gateway_proxy_header the header a proxy of this machine names a WebSocket player's address in (below)
tunnel start a free Cloudflare quick tunnel (needs cloudflared)
public_address where players reach the web port without the tunnel (1.2.3.4:27025, a name, or off); a game joining through the tunnel tries it first. Empty: found by itself (the machine's own internet address, else the one the internet sees if the server reaches itself there, never behind a carrier's NAT)
radius how many tiles round the map's first entry point are kept loaded (0: the whole map)
admin_password, moderator_password administration in the game, the web panel and POST /admin (see Administration); at least 12 characters each, empty: nobody
admin_web, admin_web_origins, admin_trusted_proxies, admin_proxy_header where the web panel (/admin/ on the web port) can be reached from: local (what a new server.cfg writes), remote through trusted proxies (passwords of at least 16 characters, else local), or off (a file from before the panel, without the key)
vehicles the buses players may drive, separated by ; (empty: every bus on the server)
share_positions GET /players on the web port (below)
accept_uploads, uploads_keep_days players' buses (below)
share_maps a player who joins without the server's map gets it from the server (the map and everything it uses, gigabytes for a big map); off (the written default), players install it themselves and are told which one is missing
voice_* voice chat (below)
public_server, public_list_url list the server in the public server list (below); the list service's address (empty: openOMSI's own)
owner_bans, require_hardware_id machine bans (below): the file of the owner's list shared by all your sessions (empty: ~/.openomsi/bans-owner.json), and turning away players whose game sends no machine identifier

server-icon.png beside server.cfg (64x64, a PNG under 256 KB) is the icon the players' list shows.

The start script that asks (run-server.cmd on Windows, a double click; run-server.sh on Linux, both beside openomsi in the server's zip): the first time it asks for the OMSI 2 folder (and checks it is a complete installation before going on), then for the main settings of server.cfg - name, players at most, the UDP and web ports, the tunnel, the admin password (typed hidden; 12 characters at least) - with what the file has in brackets, kept with Enter.

Every time, it lists the installed maps by number (the last one marked, taken with Enter) and starts the server on the one picked, without changing map in server.cfg;

the output goes to the window and to server.log (begun anew at every start, see What the server keeps about its players), and when the server stops on an error it says what the exit code means. Asked once per map, it makes start-<map>.cmd (or .sh) beside it: that starts the same map again with no question.

run-server.cmd -Setup (run-server.sh --setup) asks for the folder and the settings again; -Map maps/<folder>/global.cfg (--map …) starts a map with no question. What it remembers is in run-server.conf (the folder, the last map, the maps of the start- scripts). It speaks Portuguese on a system in Portuguese, English otherwise.

It needs no rights of an administrator; on Windows it runs in the Windows PowerShell every Windows has. start.cmd / start.sh stay as they were, for a service or another launcher.

For a launcher of its own, the program has the two pieces the script uses: openomsi --root <folder> --list-maps prints the installed maps (one a line, as server.cfg names them; the content folder's too) and ends - with code 1 and what is missing when the folder is not a complete OMSI 2, never another installation found instead;

with --server <server.cfg> it also writes a missing server.cfg with its defaults, nothing more of a server's start. --server-map maps/<folder>/global.cfg starts the server on that map instead of server.cfg's.

When it does not start, it says why on its output and ends with a code a launcher can tell apart:

exit code cause
1 the original OMSI 2 was not found at --root (the files missing are listed: a wrong folder, or an incomplete installation), or another error, printed as Error: …
2 server.cfg cannot be read or written, or its map is not installed (the maps there are listed, as server.cfg names them)
3 its UDP port is taken (another server, or another program): stop it, or choose another port

A web_port that is taken is no reason to stop: the gateway takes another port and the log says which (the status page, the WebSocket players and the tunnel are there).

The log goes to the standard error output: a launcher keeps it with the rest (start.sh writes it to server.log too; start.cmd shows it in its window), and does not take a line there for a failure - informational lines go there as well; the exit code says whether it failed. Paths with spaces or accents are passed as they are, quoted.

A map is named as in the game, relative to the OMSI 2 folder (maps/<folder>/global.cfg), and found in the content folder (mods) too.

Players reach it two ways:

  • UDP at host:port (a server with a public address, or on the LAN);
  • over a WebSocket at its web port (omsi-net::ws): every datagram is one binary message, the server's gateway gives each WebSocket a UDP socket of its own on 127.0.0.1.

    The session sees such a player there (joined from 127.0.0.1:<port>); the log says who that is (gateway: player WebSocket from <address> on 127.0.0.1:<port>), with the address a reverse proxy or tunnel on the machine forwards: the last X-Forwarded-For, else CF-Connecting-IP.

    With Cloudflare's proxy (the orange cloud) in front of a proxy of this machine, the last X-Forwarded-For is a Cloudflare edge, and the players would share a few addresses (16 connections each at most): gateway_proxy_header = cf-connecting-ip then believes Cloudflare's CF-Connecting-IP first - only with Cloudflare in front, which writes it over a client's own.

    That is what a free Cloudflare quick tunnel carries (tunnel = 1 starts cloudflared tunnel --url http://127.0.0.1:<web_port> and prints the https://….trycloudflare.com address).

    The same port answers GET /status (JSON: name, motd, map, players, max_players, time, weather, version, protocol, vehicles, and on a dedicated server world: its AI cars, buses, cars asleep, parked cars, people walking, waiting and aboard, the traffic density, whether it has passengers and the passenger density it applies now) and GET /icon.png, which the launcher's Multiplayer → Servers list shows.

    vehicles is the server's vehicles list (else every bus it has): a joining player's launcher offers only those, and so do the game menu's Place a vehicle and Swap once the game has joined.

    With an admin_password it also takes POST /admin from the machine itself: one admin command a line (clock 30600, weather set Weather/#CAVOK.owt, say …, kick 3, as the Administration menu sends them), the password in X-Admin-Password; five wrong ones in two minutes close it for a while.

    A tool beside the server (a dispatch page, a script) administers it that way without joining. A reverse proxy on the same machine connects from 127.0.0.1 as well: do not let it pass /admin on.

    With share_positions = 1 it also answers GET /players: a JSON array of the players (id, name, bus, line, destination, tour, x/y in world metres east/north, heading in degrees clockwise from north, speed_kmh, on_foot and aboard - a player on foot is where it walks (even with its own bus parked nearby), one sitting in another player's bus is with that bus (its id) - and lat/lon on a [worldcoordinates] map such as Berlin-Spandau, null elsewhere), refreshed every second - what a live map of the server on a website needs. It is off by default: the players' names and positions are then nobody's business.

Passengers. passengers = 1/0 switches the people at the stops and on the pavements on or off for the whole run (a number there is not a count: passengers = 50 reads as off).

How many there are is passenger_density, a factor on the map's own demand: the hourly [trafficdensity_passenger] of its global.cfg and each stop's own numbers, so the map's busy and quiet hours and stops stay as they are.

1 is what the map says, 0.5 half, 2 twice, from 0 to 3; it is the same factor as the game's own passengers setting (pax_density in settings.cfg), which a server without the key goes on using as before.

It is not a cap on how many people there are (that is ai_max_humans of settings.cfg), and it changes neither traffic nor the timetable's buses. 0 brings no new people while the passengers stay on; whoever already waits, walks or rides stays.

A value that is not a number from 0 to 3 (negative, NaN, 10) is refused with the reason in the log, and the server runs as if the key were not there.

An admin changes it while the server runs with passengers <factor> (the Administration menu's command, also through POST /admin): the stops get that many people from then on - nobody already there is taken away, the boarded passengers' trips go on, and the players' games only mirror the server's people, so nobody appears twice.

GET /status shows the density applied and the people waiting, walking and aboard. On a server with passengers = 0 the command is refused (the log says so).

The players can talk to each other (see VOICE.md): holding a talk key sends the player's voice, as small Opus frames, to the server, which passes it on to the players it concerns without decoding it - on the nearby channel to those within voice_range metres of the speaker (75 by default; the listeners make it quieter with the distance), on the radio channel to everybody. The server needs no audio device and stores nothing.

key default
voice 1 Voice chat at all. A player must also switch it on in their own settings (off by default), so a server that does not want the traffic says 0.
voice_radio 1 The session-wide radio channel; 0 leaves the nearby channel only.
voice_range 75 How far the nearby channel carries (5 to 1000 m).

Each player is limited to 60 frames a second (a talking player sends 50), a frame to 400 bytes; a player over it is dropped, as with every other kind of traffic.

An administrator or moderator silences a player's voice with vmute <id> (and vunmute <id>), from the player's page in the game's Administration menu or the Player list; the silence ends when the player leaves.

A server.cfg from before (with voice_server_uid, voice_channel, voice_channel_password) loads as it did: those keys are ignored and the log says so, while voice_range and voice_radio mean the above (a range under 5 m is raised to 5).

The same gateway and tunnel open for a player hosting by code (Connect by Code): its address goes to the rendezvous topic, and a joining game that gets no answer from the addresses in the code (routers that cannot be punched through) joins through the tunnel.

Chapters

1Players' buses (accept_uploads)With accept_uploads = 1 (the default) a player may drive a bus the server does not have: the player's game sends the server the files that bus uses, t…3 min
2Optional RP speed governorThe dedicated server may advertise a speed_limit_kmh of 60, 75 or 80 to players. 0 (the default) preserves normal unrestricted controls. Unrecognized …1 min
3AdministrationMultiplayer relocation (dedicated servers). A player authenticated with /admin <password> as administrator or moderator can relocate their own bus wit…13 min
4Machine bansA ban by name or address does not say who somebody is, so the lasting ban is by machine. The game sends a hardware identifier when it joins, made for …3 min
5Public server listpublic_server = 1 lists the server in the list that the launcher (Multiplayer -> Servers -> Public servers) shows. The server registers with the list …2 min
6What the server keeps about its playersTell your players what is kept (the motd is a good place). server.cfg lists the same at its end. Voice is passed on and never recorded or decoded. The…1 min
7LicenseopenOMSI is released under the GNU Affero General Public License, version 3 only (LICENSE). Its launcher preview encodes pictures with jpeg-encoder: t…1 min

Something wrong or missing? Fix it on GitHub or open an issue.

↑↓ to move↵ to open