Connecting to local LoadBalancing Server

I downloaded the Photon Server and Photon Realtime SDK's but I am having trouble getting them to run together.

I can run LoadBalancing (MyCloud) as an application through PhotonControl.exe and I can also Run TestClient and see the connections being made in the logs.
2021-01-13 11:42:24,548 [10] DEBUG Photon.SocketServer.ApplicationBase - OnInit - ConnID=1, IP on port 5056, type = ENetListener

I imported the Photon Realtime code into Unity in a folder under my Assets directory. I followed the tutorial at and followed the code samples elsewhere to create a LoadBalancingClient to connect with.

My issue is when using the LoadBalancingClient I cannot connect to the Local Server running with photon control.

I am using this class to connect with a gameobject in unity.
public class GameClass : IConnectionCallbacks, IMatchmakingCallbacks
    private readonly LoadBalancingClient client;

    public GameClass()
        client = new LoadBalancingClient();


    public void StartClient()
        client.StateChanged += OnStateChange;
        AppSettings appSettings = new AppSettings() { Server = "", Port = 5056 };


        Thread t = new Thread(Loop);
        Debug.Log("Thread Running");

    private void Loop(object state)
        while (true)

I am not sure the difference between using ConnectUsingSettings or just ConnectToMasterServer.

The code works in a way, because I immediately get the callback to OnDisconnected(DisconnectCause cause), but the cause is "unknown".

I am looking for some guidance on how to connect a client from unity to my running local server.


  • An update:

    I added this line
    client.LoadBalancingPeer.SerializationProtocolType = ExitGames.Client.Photon.SerializationProtocol.GpBinaryV16;

    to my client and it does not reject the connection anymore.

    Now I have the error "GetRegions failed. Can't provide regions list. ReturnCode: -2: Unknown operation code"

    and the DisconnectCause is returned as "InvalidAuthentication".

    I edited the Photon.LoadBalancing.dll.config to allow custom authentication
    <!-- Enable Custom Authentication by setting Enabled to "true" -->
      <AuthSettings Enabled="true" ClientAuthenticationAllowAnonymous="true">

    then I add "None" as a custom auth type to my client.
    client = new LoadBalancingClient();
            authValues = new AuthenticationValues();
            authValues.AuthType = CustomAuthenticationType.None;
            client.AuthValues = authValues;

    Unfortunately I still get an authentication failed error, so any help with this step would be appreciated :smiley:
  • The Photon Server SDK does not include the Name Server, so getting regions is not supported.
    Your client directly connects to the Master Server. ConnectToMasterServer should do the trick.
    ConnectUsingSettings should work if you set AppSettings.UseNameServer = false.
  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @partyparrot,

    Thank you for choosing Photon!

    I wanted to add a small clarification to @Tobias's answer:

    Photon Server SDK v4 does not include NameServer.
    Photon Server SDK v5 does.

    Since you mentioned the Test Client you are using v4 as the Test Client was removed in v5.
    So either do as @Tobias said or use v5.