JoinRoom create new room
Options
Hi!
I have problem, in my game room can not exist when all users disconnected.
1) I use Photon + PlayFab
2) Game work on mobile (now only Android) and when device was paused I disconnect player
4) I used next code to reconnect:
5) my date from playFab analytics:
when room was created in first time (8:04):
I have problem, in my game room can not exist when all users disconnected.
1) I use Photon + PlayFab
2) Game work on mobile (now only Android) and when device was paused I disconnect player
void OnApplicationPause(bool pauseStatus) { if (pauseStatus) PhotonNetwork.Disconnect (); }3) I create room with second settings:
public void OnPhotonRandomJoinFailed() { PhotonNetwork.CreateRoom(Game.Id, new RoomOptions() { MaxPlayers = 2, PublishUserId = true, IsVisible = true, PlayerTtl = 0, EmptyRoomTtl = 0 }, null); }
4) I used next code to reconnect:
protected override void OnScheduledUpdate () { base.OnScheduledUpdate (); if (!PhotonNetwork.connectedAndReady) { if(PhotonNetwork.connectionState == ConnectionState.Disconnected ) PhotonNetwork.Reconnect (); _reconnectCounter++; return; } UnscheduleUpdate (); PhotonNetwork.JoinRoom (AppModel.Instance.Game.Id); }this function work like update but I can stop it use UnscheduleUpdate() and in AppModel I saved last room id
5) my date from playFab analytics:
when room was created in first time (8:04):
JSON { "EventName": "room_created", "EventNamespace": "title.3AE3", "EntityType": "title", "Source": "3AE3", "EventId": "36212b497f0b4ff2af99f25db9790efc", "EntityId": "3AE3", "SourceType": "GameServer", "Timestamp": "2017-09-07T08:04:51.3984748Z", "History": null, "CustomTags": null, "Reserved": null, "GameId": "cd6db763-e105-42d0-9a05-95299e29cab8", "Region": "EU", "Type": "Create", "UserId": "5D25C0ECF28959E" }when room was closed (8:05)
JSON { "EventName": "room_closed", "EventNamespace": "title.3AE3", "EntityType": "title", "Source": "3AE3", "EventId": "a1b4270f1d0849d09cccfab54f8eae4c", "EntityId": "3AE3", "SourceType": "GameServer", "Timestamp": "2017-09-07T08:05:15.2271116Z", "History": null, "CustomTags": null, "Reserved": null, "GameId": "cd6db763-e105-42d0-9a05-95299e29cab8", "Region": "EU", "Type": "Close" }when room was create in second time (8:05)
JSON { "EventName": "room_created", "EventNamespace": "title.3AE3", "EntityType": "title", "Source": "3AE3", "EventId": "f06695d7fe3c4e5c9a7b16c05cca9da0", "EntityId": "3AE3", "SourceType": "GameServer", "Timestamp": "2017-09-07T08:05:25.7890347Z", "History": null, "CustomTags": null, "Reserved": null, "GameId": "cd6db763-e105-42d0-9a05-95299e29cab8", "Region": "EU", "Type": "Load", "UserId": "5D25C0ECF28959E" }
0
Comments
-
oops it not correct category. Can somebody change with DotNet to Unity (PUN)?0
-
Hi @Oleksii,
Thank you for choosing Photon!
I moved discussion to PUN category.
I see you have webhooks enabled and you implemented them on CloudCode nicely by adding custom PlayStream events.
I think there is a call toRejoin
somewhere. If it's not done explicitly by you then it may have been called internally and this case is unhandled or not handled properly.
Look forPhotonNetwork.Rejoin
orPhotonNetwork.ReconnectAndRejoin
calls and add a log there to see when this happens.
If you want to disable this altogether, you need to talk to PlayFab to change the webhooks settings for your Photon app as they have access to the dashboard. Basically you need "IsPersistent = false".
0 -
Yes you're right, the call to rejoin should fail in that case and you should get an error on client.
I'm not sure if webhook is forwarded in this case.
Maybe this is a case of AsyncJoin, send me your AppId in private so I can check.
Or maybe you are using different AppVersion or PUN versions?
If you can add all webhooks arguments to PlayStream events (like ActorNr), reproduce and then send us all webhooks sequence and details that would help a lot in investigating this.0 -
OK I checked logs and config.
On the client you should receive room join errors, something like (I'm quoting server log):Game 'f93af7c6-5e2f-4b6c-b689-3c82ea0b4ee8' userId '5D25C0ECF28959E' failed to join. msg:'Actor with number 0 not found.' (JoinMode=3)
I still believe it's a rejoin (with 'Load') that fails.
PUN does not check PlayerTTL, EmptyRoomTTL or how long app was paused.
So here is what I suggest:
- useConnect
instead ofReconnect
.
- log calls toRejoin
even if it's called internally by PUN.1 -
@JohnTube
It give same result
room was created when I use JoinRoom
my code naw:protected override void OnScheduledUpdate () { base.OnScheduledUpdate (); if (PhotonNetwork.GetPing () == 0) return; if (!PhotonNetwork.connectedAndReady) { if (PhotonNetwork.connectionState == ConnectionState.Disconnected) PhotonNetwork.ConnectUsingSettings (Application.version); return; } UnscheduleUpdate (); PhotonNetwork.JoinRoom (AppModel.Instance.Game.Id); }
and my second create room (2:05) log:JSON { "EventName": "room_created", "EventNamespace": "title.3AE3", "EntityType": "title", "Source": "3AE3", "EventId": "797d9639ee194df99395546479b92007", "EntityId": "3AE3", "SourceType": "GameServer", "Timestamp": "2017-09-08T14:05:26.691404Z", "History": null, "CustomTags": null, "Reserved": null, "GameId": "f402b1e1-9041-41db-977b-5d2dae4134c7", "Region": "EU", "Type": "Load", "UserId": "2A4F204DB220C988" }
0 -
mb I need check is Room exist?
if (NetController.Instance.IsRoomExist (AppModel.Instance.Game.Id)) PhotonNetwork.JoinRoom (AppModel.Instance.Game.Id);
public bool IsRoomExist(string roomName) { List<RoomInfo> roomList = PhotonNetwork.GetRoomList().ToList(); RoomInfo room = roomList.FirstOrDefault(r => r.Name == roomName); return (room != null); }
But this code always return false (roomList is empty)0 -
And when I reconnected server time changed (not for few seconds, it's large number)0
-
Hi @Oleksii,
Client does not need to check if rooms exist, never.
Not directly related to the issue in hand:IsRoomExist
(preciselyPhotonNetwork.GetRoomList()
) should work only insideOnReceivedRoomListUpdate()
callback.
So you may need to cache rooms list in case you need it and you should take into consideration frequency of events.And when I reconnected server time changed (not for few seconds, it's large number)What do you mean?
- As I told you above, add all args to PlayStream events so we can know everything about webhooks.
- TryJoinRoom()
orRejoinRoom()
for non existing games to see what happens:string shortGuid = Convert.ToBase64String(Guid.NewGuid().ToByteArray()) .Substring(0, 22) .Replace("/", "_") .Replace("+", "-"); PhotonNetwork.JoinRoom(shortGuid); //PhotonNetwork.RejoinRoom(shortGuid);
- Also, try avoiding object initialization it may still have a bug in Unity/mono:
just to make sure replacepublic void OnPhotonRandomJoinFailed() { PhotonNetwork.CreateRoom(Game.Id, new RoomOptions() { MaxPlayers = 2, PublishUserId = true, IsVisible = true, PlayerTtl = 0, EmptyRoomTtl = 0 }, null); }
with:public void OnPhotonRandomJoinFailed() { RoomOptions roomOptions = new RoomOptions(); roomOptions.MaxPlayers = 2; roomOptions.PublishUserId = true; roomOptions.IsVisible = true; roomOptions.PlayerTtl = 0; roomOptions.EmptyRoomTtl = 0; PhotonNetwork.CreateRoom(Game.Id, roomOptions, null); }
0 -
OK @Oleksii thank you for your report and patience.
I managed to reproduce and identify the issue.
We will investigate further and let you know.
I apologize about the inconvenience.
We can if you agree update your webhooks config to fix this from config but it's a "workaround".
The idea is to disable Persistence by setting "IsPersistent = false".
If you agree let me know.
Do you know when you started to see/have this issue?
When did you first spot it?0 -
Another fix is to change CloudScript as follows:
handlers.RoomCreated = function (args) { if (args.Type === "Load") { return {ResultCode: 1, Message: "Room does not exist!"}; } }
0 -
OK, let's tryJohnTube said:
We can if you agree update your webhooks config to fix this from config but it's a "workaround".
The idea is to disable Persistence by setting "IsPersistent = false".
If you agree let me know.
I was started "reconnect" part of my project 1 week ago, before I did not check my analytics...JohnTube said:
Do you know when you started to see/have this issue?
When did you first spot it?
I used Unity 5.6.0.p2
PUN (in change log last version) v1.84.1 (2. June 2017)
PlayFab SDK 2.24.1707100