GetPeerID change every time I create a room


I have seen while debugging that the peerId of a user changes really often, each time I create a new room, it seems that my peerId change. I would like to know if this is normal behavior or is it that I did something wrong ?


  • Kaiserludi
    Kaiserludi admin
    edited February 2020
    Hi @benjaml.

    Yes, this is perfectly normal and expected.

    Photon Cloud consists of a name server (that in reality is actually split across multiple servers around the world, but to the Photon client appears just as one server) and multiple Photon regions. Each of these regions consists of 1 or more clusters. Each cluster consists of 1 master server and up to multiple dozens of game servers. Each of those Photon servers will assign a peerID to a client that connects to it via UDP and this peerID is valid for as long as the client is connected to this specific Photon server.

    The client initially connects to the nameserver and retrieves the list of available regions. It then disconnects and connects to the master server of one of the clusters of one of those regions.
    From there on every time the client creates or joins a room it receives instructions from that master server about which game server it should connect to to enter that room. The client then disconnects from the master and connects to the game server to which the master server told it to connect to. Once it leaves the room, it disconnects from that game server and returns to the master server.

    Each time such a switch of the server to which the client is connected to happens, that new server will assign a new peerID to the client.

    This is all done automatically under the hood by class LoadBalancing::Client and your code does not need to know anything about these implementation details.