Connected but failed to create room

After successfully connected to my server, I call the joinRandomRoom function on the on connected to master and on lobby connected functions each. When the random fails, I simply create a room. However, the room is unable to be created and I confirmed this with a OnCreateRoomFailed event. Why is it failing to create a room?

The callbacks are being called correctly, which makes me think the server configuration is correct. The master is called first, the issue is with the method "CreateRoom".

I have attached my code and debug log.
Any help would be much appreciated.
using System.Collections;
using System.Collections.Generic;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;

public class connect : MonoBehaviourPunCallbacks
{
    bool connected = false;

    // Start is called before the first frame update
    void Start()
    {
        ConnectNow();
    }

    public void ConnectNow()
    {
        if (connected) return;
        connected = PhotonNetwork.ConnectToMaster("NETWORK", 5056, "");
        // debug
        // TODO: implement proper error handling
        if (!connected) {
            Debug.Log("Failed to Connect to master @NETWORK");
        }
    }

    // invoke join random room
    public override void OnConnectedToMaster()
    {
        Debug.Log("^^^ Connected to master @ net"); // debug
        RoomOptions roomOptions = new RoomOptions() { MaxPlayers = 2 };
        //PhotonNetwork.JoinOrCreateRoom("", roomOptions, TypedLobby.Default);
        PhotonNetwork.JoinRandomRoom();
    }

    // join random room once in default lobby
    // TODO: wait for matchmaking button
    public override void OnJoinedLobby()
    {
        Debug.Log("Joined Lobby Succesfully! Joinin rando room or creating now"); // debug
        RoomOptions roomOptions = new RoomOptions() { MaxPlayers = 2 };
        //PhotonNetwork.JoinOrCreateRoom("", roomOptions, TypedLobby.Default);
        PhotonNetwork.JoinRandomRoom();
    }

    // create room if random failed
    public override void OnJoinRandomFailed(short returnCode, string message)
    {
        Debug.Log("Failed join room, creating..."); // debug
        Debug.Log(message);
        RoomOptions roomOptions = new RoomOptions() { MaxPlayers = 2 };
        PhotonNetwork.CreateRoom(null, roomOptions);
    }

    public override void OnCreateRoomFailed(short returnCode, string message)
    {
        Debug.Log("failed to create room dude :((((");
        Debug.Log(message);
    }

    // print out disconnect error
    // TODO: visual error handling in app
    public override void OnDisconnected(DisconnectCause cause)
    {
        Debug.Log("Disconnected for: " + cause); // debug);
    }

    // print room joined man
    public override void OnJoinedRoom()
    {
        Debug.Log("Joined Room BRUH pls sleep man");// debug
    }
}

unity output:
2020-09-21 03:10:01.224991-0700 Towerito[768:90509] Built from '2019.3/staging' branch, Version '2019.3.0f5 (44796c9d3c2c)', Build type 'Development', Scripting Backend 'il2cpp'
-> applicationDidFinishLaunching()
PlayerConnection initialized from /private/var/containers/Bundle/Application/4FD73691-41BB-4915-B105-9423E425FC22/Towerito.app/Data (debug = 0)
PlayerConnection initialized network socket : 0.0.0.0 55000
Multi-casting "[IP] 100.79.203.81 [Port] 55000 [Flags] 2 [Guid] 2975787072 [EditorId] 1734683849 [Version] 1048832 [Id] iPhonePlayer(Jacobs-iPhone):56000 [Debug] 0 [PackageName] iPhonePlayer [ProjectName] Towerito" to [225.0.0.222:54997]...
Started listening to [0.0.0.0:55000]
PlayerConnection already initialized - listening to [0.0.0.0:55000]
-> applicationDidBecomeActive()
[Subsystems] Discovering subsystems at path /private/var/containers/Bundle/Application/4FD73691-41BB-4915-B105-9423E425FC22/Towerito.app/Data/UnitySubsystems
GfxDevice: creating device client; threaded=1
Initializing Metal device caps: Apple A13 GPU
Initialize engine version: 2019.3.0f5 (44796c9d3c2c)
New input system (experimental) initialized
2020-09-21 03:10:01.639125-0700 Towerito[768:90509] Unbalanced calls to begin/end appearance transitions for <SplashScreenController: 0x13134ec60>.
UnloadTime: 2.533167 ms
Setting up 1 worker threads for Enlighten.
  Thread -> id: 16c46b000 -> priority: 1 
2020-09-21 03:10:03.872610-0700 Towerito[768:90755] [si_destination_compare] send failed: Invalid argument
2020-09-21 03:10:03.872756-0700 Towerito[768:90755] [si_destination_compare] send failed: Undefined error: 0
^^^ Connected to master @ net
connect:OnConnectedToMaster()
Photon.Realtime.ConnectionCallbacksContainer:OnConnectedToMaster()
Photon.Realtime.LoadBalancingClient:OnOperationResponse(OperationResponse)
ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(StreamBuffer)
ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
Photon.Pun.PhotonHandler:Dispatch()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

Failed join room, creating...
connect:OnJoinRandomFailed(Int16, String)
Photon.Realtime.MatchMakingCallbacksContainer:OnJoinRandomFailed(Int16, String)
Photon.Realtime.LoadBalancingClient:OnOperationResponse(OperationResponse)
ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(StreamBuffer)
ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
Photon.Pun.PhotonHandler:Dispatch()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

Unknown operation code
connect:OnJoinRandomFailed(Int16, String)
Photon.Realtime.MatchMakingCallbacksContainer:OnJoinRandomFailed(Int16, String)
Photon.Realtime.LoadBalancingClient:OnOperationResponse(OperationResponse)
ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(StreamBuffer)
ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
Photon.Pun.PhotonHandler:Dispatch()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

failed to create room dude :((((
connect:OnCreateRoomFailed(Int16, String)
Photon.Realtime.MatchMakingCallbacksContainer:OnCreateRoomFailed(Int16, String)
Photon.Realtime.LoadBalancingClient:OnOperationResponse(OperationResponse)
ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(StreamBuffer)
ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
Photon.Pun.PhotonHandler:Dispatch()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

Missing value 255 (JoinGameRequest.GameId)


Photon.Realtime.MatchMakingCallbacksContainer:OnCreateRoomFailed(Int16, String)
Photon.Realtime.LoadBalancingClient:OnOperationResponse(OperationResponse)
ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(StreamBuffer)
ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
Photon.Pun.PhotonHandler:Dispatch()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

Comments

  • Keep in mind I have IPv6 clients with an Ipv6 server, if that makes any difference. I even followed the tutorial from https://doc.photonengine.com/zh-tw/pun/v2/demos-and-tutorials/pun-basics-tutorial/lobby and am coming up with the same room creation error.
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited September 2020
    Hi @JPGOrdon,

    Thank you for choosing Photon!

    So you are using a self-hosted Photon Server.

    Change port to 5055.

    Which Photon Server SDK version do you use?

    Port number 5056 is by default for the Game Server, not the Master Server (5055).
    Are you sure you have the correct configuration?

    Not sure what you did but from the two error messages for JoinRandomRoom ("Unknown operation code") and CreateRoom ("Missing value 255 (JoinGameRequest.GameId)"), it looks like you connected to Game Server and not Master Server.

    Not sure how this could happen, I thought a client cannot connect directly to a Game Server without authenticating on Master Server or Name Server first.

    Side notes:
    I recommend you edit your post and hide your server address for security reasons.
    You can use PUN 2's ConnectUsingSettings to connect to your on-premises server by setting the appropriate PhotonServerSettings.
  • JPGOrdon
    JPGOrdon
    edited September 2020
    I am connecting to the master correctly because its callback is invoked, as suggested in the logs. I am connecting to my master server using a DNS and don't specify a port. The callbacks are being called in the correct order it seems. Should I specify a port when connecting to my master for this reason? Is this simply the reason why the room is failing, even though the master callback is being invoked?

    I assume the error code for "JoinRandomRoom" would be because there were no open rooms in my instance. The second error code perplexes me.

    As a side note, in my current setup, the game servers and main servers are hosted on the same VM. I did get this same setup working on my laptop (instead of my iOS device), so I am guessing this to be an issue with my client code. I am using the latest SDk for server v4 and .NET 3.5, which my Windows Server was forcing me to use.
  • These errors occured because of the port I was connecting to upon "ConnectToMaster" invokation. When you connect to a master, it will always be port 5055 like @JohnTube suggested. Hope this helps others.