Disconnecting when join or create a room
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on PUN.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
Disconnecting when join or create a room
WanChen
2022-12-04 19:27:26
When i try to join or create a room , the client will get disconnected.
I used PhotonNetwork.JoinOrCreateRoom
and the return was true, but no callback was called.
This is the log message:
private void Start()
{
if (DebugMode)
{
roomName = "Debug";
Initialize();
}
}
public void Initialize()
{
PhotonNetwork.ConnectUsingSettings();
}
public override void OnConnectedToMaster()
{
Debug.Log("ConnectedToMaster");
PhotonNetwork.JoinLobby();
}
public override void OnJoinedLobby()
{
Debug.Log("JoinedLobby");
CreateOrJoinRoom();
}
public void CreateOrJoinRoom()
{
RoomOptions options = new RoomOptions { MaxPlayers = 2 };
Debug.Log("CreateOrJoinRoom");
bool a = PhotonNetwork.JoinOrCreateRoom(roomName, options, default);
Debug.Log(a);
}
public override void OnJoinedRoom()
{
Debug.Log("JoinedRoom");
PhotonNetwork.Instantiate(player.name, Vector3.zero, Quaternion.identity);
}
public override void OnCreatedRoom()
{
Debug.Log("CreatedRoom");
}
public override void OnCreateRoomFailed(short returnCode, string message)
{
Debug.Log("CreateRoomFailed");
Debug.Log(returnCode);
Debug.Log(message);
}
public override void OnJoinRoomFailed(short returnCode, string message)
{
Debug.Log("JoinRoomFailed");
Debug.Log(returnCode);
Debug.Log(message);
}
Comments
Those logs are for Photon Voice, not PUN. For some reason, the Voice client gets disconnected.
Maybe you are not using the correct AppId for it. The type of the Voice app should be "Voice" and if it's Fusion (e.g.) this would disconnect you.
I found the problem. The time-out leads to the disconnect. How can i solve it?
It looks as if your client is not receiving anything.
Check your firewall if it blocks the port (the log should contain the IP and port, too). Also try the alternative ports. Check if your antivirus or ISP randomly have one of our IPs on their block lists (this happened earlier but it's impossible for us to check or prevent this).
Back to top