The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

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).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

[SOLVED] DisconnectByServerLogic and Game closed error from OnJoinRoomFailed

Bubuzam
2019-10-24 23:37:07

I'm having a problem on the game I'm developing. When I try to put more than 4 players in the some room, some issues appear.
Basically when I try to log in the fifth player, I got this:

Disconnected because: DisconnectByServerLogic
UnityEngine.Debug:Log(Object, Object)
PhotonLobby:OnDisconnected(DisconnectCause) (at Assets/Scripts/PhotonLobby.cs:57)
Photon.Realtime.ConnectionCallbacksContainer:OnDisconnected(DisconnectCause) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:3438)
Photon.Realtime.LoadBalancingClient:OnStatusChanged(StatusCode) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2557)
ExitGames.Client.Photon.<>c__DisplayClass105_0:b__0() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PeerBase.cs:907)
ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/EnetPeer.cs:431)
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PhotonPeer.cs:1596)
Photon.Pun.PhotonHandler:Dispatch() (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:205)
Photon.Pun.PhotonHandler:FixedUpdate() (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:139)

Couldn't entered the room because: User does not exist in this game
UnityEngine.Debug:Log(Object)
PhotonLobby:OnJoinRoomFailed(Int16, String) (at Assets/Scripts/PhotonLobby.cs:71)
Photon.Realtime.MatchMakingCallbacksContainer:OnJoinRoomFailed(Int16, String) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:3525)
Photon.Realtime.LoadBalancingClient:CallbackRoomEnterFailed(OperationResponse) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2104)
Photon.Realtime.LoadBalancingClient:OnOperationResponse(OperationResponse) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2244)
ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(StreamBuffer) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PeerBase.cs:620)
ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/EnetPeer.cs:548)
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PhotonPeer.cs:1596)
Photon.Pun.PhotonHandler:Dispatch() (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:205)
Photon.Pun.PhotonHandler:FixedUpdate() (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:139)

RaiseEvent(202) failed. Your event is not being sent! Check if your are in a Room
UnityEngine.Debug:LogWarning(Object)
Photon.Pun.PhotonNetwork:RaiseEventInternal(Byte, Object, RaiseEventOptions, SendOptions) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:2213)
Photon.Pun.PhotonNetwork:SendInstantiate(InstantiateParameters, Boolean) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:2562)
Photon.Pun.PhotonNetwork:NetworkInstantiate(InstantiateParameters, Boolean, Boolean) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:2486)
Photon.Pun.PhotonNetwork:Instantiate(String, Vector3, Quaternion, Byte, Object[]) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:2336)
d__13:MoveNext() (at Assets/Scripts/PhotonLobby.cs:113)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

And then, after a while trying, I got this:

Couldn't entered the room because: Game closed
UnityEngine.Debug:Log(Object)
PhotonLobby:OnJoinRoomFailed(Int16, String) (at Assets/Scripts/PhotonLobby.cs:71)
Photon.Realtime.MatchMakingCallbacksContainer:OnJoinRoomFailed(Int16, String) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:3525)
Photon.Realtime.LoadBalancingClient:CallbackRoomEnterFailed(OperationResponse) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2104)
Photon.Realtime.LoadBalancingClient:OnOperationResponse(OperationResponse) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2337)
ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(StreamBuffer) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PeerBase.cs:620)
ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/EnetPeer.cs:548)
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PhotonPeer.cs:1596)
Photon.Pun.PhotonHandler:Dispatch() (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:205)
Photon.Pun.PhotonHandler:FixedUpdate() (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:139)

This is the SupportLogger info when I'm trying:

[12.216] SupportLogger Rtt(variance): 55(7). Since receive: 1ms. Longest send: 1ms. Stats elapsed: 10sec.
Longest delta between Send: 116ms Dispatch: 251ms. Longest callback OnEv: 226=3ms OnResp: 230=7ms. Calls of Send: 199 Dispatch: 507. Ping min/max: 47/55
UnityEngine.Debug:Log(Object)
Photon.Realtime.SupportLogger:LogStats() (at Assets/Photon/PhotonRealtime/Code/SupportLogger.cs:185)

I don't know what to do and I really aprecciate if you guys could help me :smile:

Comments

Bubuzam
2019-10-24 23:38:48

This is the code of my connection:

using System.Collections;  
using UnityEngine;  
using Photon.Pun;  
using Photon.Realtime;  
using Photon.Voice.PUN;  
#if PLATFORM_ANDROID  
using UnityEngine.Android;  
#endif

public class PhotonLobby : MonoBehaviourPunCallbacks
{
public static PhotonLobby lobby;
public bool OfflineMode;

#if PLATFORM_ANDROID
if (!Permission.HasUserAuthorizedPermission(Permission.Microphone))
{
Permission.RequestUserPermission(Permission.Microphone);

#endif

#if UNITY_ANDROID
if (!Permission.HasUserAuthorizedPermission(Permission.Microphone))
{
Application.Quit(1);
}
#endif

}

JohnTube
2019-10-25 10:52:33

Hi @Bubuzam,

Thank you for choosing Photon!

What PUN 2 version you use?
Do you connect to Photon Cloud or self-hosted Photon Server?
What protocol do you use?

Do you send too many events or too much data on join?
I don't see that in the code you shared but maybe in another script?

And closing the room, maybe you do it on another script?
room.IsOpen = false

Also, I see that you first try to create a room then if it exists you try to join it. I think you could make use of JoinOrCreateRoom method.

Anyway, other than answering those questions, you could take a look at "Analyzing Disconnects".

Bubuzam
2019-10-25 12:58:45

Thanks for answering me, JohnTube :)

My version is Pun: 2.15 Photon lib: 4.1.2.18
Connection through Photon Cloud and I use default Protocol: Udp

room.IsOpen = false
I only discover this command some days ago, when I was trying to fix this problem, so I'm sure that it doesn't exist in my code. I'm guessing that the room is being closed for some security reason because the player is trying to go into the room but these Disconnections ByServerLogic are happening instead
Also, I see that you first try to create a room then if it exists you try to join it. I think you could make use of JoinOrCreateRoom method.
I used to use this command, but I separated in Create e Join for debugging this error
Anyway, other than answering those questions, you could take a look at "Analyzing Disconnects".
I read It already and It helped me with others disconnecting problems, but not with this one :disappointed:

JohnTube
2019-10-25 13:04:21

Hi @Bubuzam,

Send an email to [email protected] with your AppId and AppVersion and Region.
Plus minimal repro steps and link to this forum thread.

Bubuzam
2019-10-25 16:14:02

Thanks JohnTube, I just found out the problem when I was defining the minimal programming steps to reproduce the error.
One of my scripts was calling constantly a RPC. So I just rewrite it to call the RPC only on changes, fixing the problem. Problably it was calling around 100msgs/s per player and when I was joining with 5 players, it was exceeding the maximum from the server and it was closing the room. SOLVED

Back to top