Frequent Disconnections (MasterTimeout- 1004 , GameTimeout - 2004)

Hello folks,

I have been using photon for quite some time now, mostly used PUN2 in unity and never had any issues regarding frequent disconnections.
I have a turn based game (made in cocos creator) in which I have integrated latest JS SDK with demoloadbalancing, following things I had tried but issue was not solved:

1) Used WSS (secure web socket) of photon cloud
2) Tried my game on different networks, browsers, devices, systems, ocurance is almost same ; about 4 out of 10
3) Tried on different regions (even calculated ping of the closet region and assign that region as well)
4) Ping closet server (own php server and google as well) to check real time ping of the device (network latency to investigae issue)
5) Investigae JS heap size allocation so to rule out any memory leak issues
6) Tried changing connect options, "keepMasterConnection", when calling "ConnectToRegionMaster"
7) Tried tweaking values for "keepAliveTimeoutMs" in SDK
8) Made sure browser don't go into pause state and browser is not halting JS processing
9) Studied all steps mentioned here, and carefully followed them

I have hit a wall now, really need to fix this ASAP, as it has delayed my final deadline two times in a row now, please guide me. I'm open to any solution possible.

NOTE: If I need to provide some test results or code please feel free to ask.


Humza Khalid


  • Hi Humza,
    Can you reproduce disconnects with any of demos provided with SDK? What are the steps to reproduce? Does client disconnect also when nothing is sent or only when the client sends a lot? Are disconnects more frequent when browser page is in background?
    Please share the appid which you use for test in an email to [email protected] with a link to this page or post any 4 sequencial symbols of appid here.
  • Hi, thanks for replying,
    I haven't tested the required demos thouroughly but do ran them few times for testing.
    Its really hard for me to tell exact reproduce steps as its inconsistent and varies through out game testing sessions.
    I think client disconnects when there is nothing to sent, but I have tested "resetKeepAlive" to be called after 3 seconds of interval in any case , even if im not sending any packets, so im not sure and its a turn based game so minimal data is sent on events so I think it will not be the case of sending too much data.

    I will be sending you email right away.
  • vadim
    vadim mod
    edited March 2021
    I did not have any disconnects when tested your appid. If you can't reproduce disconnects with the demo from SDK, there is probably something wrong with your app.
    resetKeepAlive is called automatically once per second. Calling it less frequently while not sending anything will lead to disconnect. If you use Loadbalancing or Chat API, you don't have access to resetKeepAlive. Or you use Photon peer directly?
  • We also noticed that you regularly reach free 20 CCU limit. Server rejects new connections above this limit. But already established connections should not be affected I guess.
    Make sure that you always have < 20 running clients.
  • hello,
    Thank you for your detail inspection,
    resetKeepAlive is being called autmatically by LoadBalamcingClient,I tweaked its frequency once in sdk itself but nothing changed so reverted it back to original.
    Yes I also see CCU max usage , ill try to create new realtime ID to test and if its confirms ill buy a subscription.