Skip to main content

How do I get roomId from my game server?

You will need to access roomId from an active process if you're using an API endpoint that uses it as a parameter (i.e. GetLobbyInfoByRoomId(), UpdateRoomConfig(), GetRoomInfo()).

Hathora will dynamically schedule rooms on an active processs if:

  1. A room is destroyed once a match completes and another CreateRoom() request arrives before that process has been terminated
  2. Your deployment has roomsPerProcess > 1, meaning multiple rooms can be assigned to the same process Since environment variables are immutable once a process starts, Hathora cannot pass in roomId as a default environment variable.

Instead, Hathora passes in a HATHORA_PROCESS_ID is an environment variable which you can use to call the GetActiveRoomsForProcess() endpoint. GetActiveRoomsForProcess() returns an array of roomIds so you can grab the first element if you've set roomsPerProcess = 1.