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.

PhotonNetowrk.Isconnected true, client state: leaving, sometimes gets stuck like this

hellohallo
2020-04-27 07:19:15

So normally I am able to leave the room fine by clicking a button, however sometimes we get stuck where we are connected to the network and our client state is leaving, but the client never actually leaves. I then get the following error:

Operation LeaveRoom (254) not called because client is not connected or not ready yet, client state: Leaving

We are connected to the network in this case because the leaveroom will only be called if we are. so why is client state stuck in 'leaving' and yet never actually leaves?

what is the best way to elegantly recover from this? I would say it happens about 1 in 10 times.

any advice appreciated. thanks.

Comments

JohnTube
2020-04-27 09:50:11

Hi @hellohallo,

Thank you for choosing Photon!

Operation LeaveRoom (254) not called because client is not connected or not ready yet, client state: Leaving

This means you called LeaveRoom more than once.
The first time worked which changed the client state to Leaving and the other call failed with this error.

Maybe the client is not really stuck.
Did you implement OnLeftRoom callback?

hellohallo
2020-04-27 11:58:43

Yes I am implementing OnLeftRoom callback and it is getting called normally. The issue only occurs rarely, but I've added some more logging now, so when it happens again I'll have more info. Thanks

hellohallo
2020-04-27 12:00:41

is it possible for the client to leave the room but the callback not to be called or would it be called in 100% of cases?

is it possible that the client tries to leave the room but fails? if it is possible what state will it get set to if it tries and fails?

JohnTube
2020-04-27 13:20:17

Hi @hellohallo,

is it possible for the client to leave the room but the callback not to be called or would it be called in 100% of cases?

No, this should not happen. You could try to catch this inside OnOperationResponse, case OperationCode.Leave and operationResponse.ReturnCode != ErrorCode.Ok. But operation leave should not return an error unless you call it on the wrong server or when the client is not joined to a room, this cannot happen as we have client checks in place, unless you modified client code.

is it possible that the client tries to leave the room but fails? if it is possible what state will it get set to if it tries and fails?

Yes, check return value of LeaveRoom method and the logs for errors. The client state does not change in this case.

hellohallo
2020-04-28 01:54:43

Ok it happened again, but I didn't have logging to check the return value of LeaveRoom so I've just added that logging and well as logging for the clientstate before and after, so will have a more complete picture next time.

@JohnTube wrote: »

Yes, check return value of LeaveRoom method and the logs for errors. The client state does not change in this case.

So if we try and fail to leave the room, the client state will remain as leaving and we will not longer try to leave? Or should the client state be set back to something else if we fail to leave?

Back to top