Operation 227 - failed, "isConnected" is false , "isClosing" is false

I have a 1 vs 1 multiplayer browser game where I am utilizing Photon Realtime JS SDK. I have a system where I detect other player from leaving the browser tab (with Page Visibility API). Now, I want to make is so that if the other player remains inactive (on the other browser tab) for 10 seconds, he/she will be disconnected.

All works fine, but when I call leaveRoom() on the client that is inactive, I get error "Operation 227 - failed, "isConnected" is false , "isClosing" is false".

Is this because somehow the server already knows that the client is not connected? And what is the workaround?

Comments

  • In fact, does Photon realtime already keep track of the clients visiblity? I would think s, because for example custom events raised fire when client comes back to the page. Is there some variable in Photon that would save the state of the client (page visible or not)?
  • The server regards the client as disconnected if the client does not send any user or special ping messages for a few seconds. This may happen if connection to the Internet is lost or browser tab is closed or js engine is suspended somehow.
    Alternatively and more preferably, you may use leaveRoom() or disconnect() methods which disconnect instantly.