Frequent disconnects from Photon Cloud Server in Unity WebGL PUN+

We are experiencing frequent disconnects from the Photon Cloud Server with:

WebSocket is already in CLOSING or CLOSED state._SocketSend...
Exiting receive thread (inside loop) due to error: Abnormal disconnection.

Is there any known solution or advice on how to deal with this?

Comments

  • Is your internet connection reliable enough?
    Does PUN demos fail as well?
    What is browser / platform do you use?
    Any other errors in browser log?
  • Of course we have reliable internet connection. We didn't check the PUN demos.

    Disconnects only happen on the WebGL platform, in any browser.
    Webplayer is stable with no disconnects. We use Unity 5.1.2 with PUN+ 1.60, Cloud Server.

    They are intermittent, though - one might play for 10 minutes+ with no disconnects or get one after 2-3 minutes or even a few seconds. The behavior and the message in the console.log upon disconnect:

    WebSocket is already in CLOSING or CLOSED state.

    is similar to a timed-out disconnect for abandoned browser sessions.

    One of the messages we see in the log, besides the one I posted above is:

    "QueueIncomingReliableWarning. This client buffers many incoming messages. This is OK temporarily. With lots of these warnings, check if you send too much or execute messages too slow. "

    We see only two warnings like this in the very beginning, though.

    We've read through: https://doc.photonengine.com/ko-kr/realtime/current/reference/analyzing-disconnects, and enabled CRC checks, but this didn't change anything. It's not clear how to "Call Service Regularly", but then you docs say "Only PUN will do this automatically!".










  • Hi, I'm having the same problem. Did you find a solution?
  • Do demos provided with PUN disconnect same way as your app?
    In case demos work ok, could you please send simple test which replicates your data sending pattern and disconnects regularly?
  • Yes, I was able to reproduce it in the demoboxes in a webgl build. However, it only happened when I opened several windows of the same build.

    I guess what happens is that the client disconnects when it can't get the messages through... I'll look up how to curb this...

    Thanks for your help. I'll let you know if I run into more trouble.

    You can find the game I'm talking about here: RAWAR

  • Ok, so I found the solution.

    I was sending quite an amount of data when a new client connected. I know I'm not supposed to do this, but my game needs it this way.

    I resolved it by sending the data in 2 batches (with a delay for the second batch) and stripping as much data as I could :)

    It's rather strange that only WebGL has this problem, but if it works, it works :)

    -- Daan
  • Glad to know that you found the reason and solution.
    Probably non-webgl client was close to "too much data" threshold whereas webgl with more traffic overhead was above it
  • JohnTube
    JohnTube ✭✭✭✭✭
    @DaanK
    Maybe this is offtopic but I want to tell you that your game is awesome! It deserves better polishing.
  • Same problem here.
    Game works great on all possible platforms (Editor, exe, web player, ios, android, wp8) but on WebGL we always get disconnected. Sometimes when new player connected, sometimes after a few minutes of play.

    Disconnects is only if Master Client is WebGL in browser (Firefox and Chrome).
    If Master in editor - all is ok.

    Unity 5.2.1f1, Photon 1.61

    Nothing strange in Full log for Photon and/or Development build.

    Full error log from browser:
    Exiting receive thread (inside loop) due to error: Abnormal disconnection.
    
    _JS_Log_Dump() WebGL.js:8655
    __Z40DebugStringToFilePostprocessedStacktracePKcS0_S0_iS0_iiiiPFvRK11CppLogEntryE() WebGL.js:887760
    __Z17DebugStringToFilePKciS0_iiiiPFvRK11CppLogEntryE() WebGL.js:887607
    __Z25Debug_CUSTOM_Internal_LogiP15ScriptingStringP15ScriptingObject() WebGL.js:932752
    _Debug_Internal_Log_m5266() WebGL.js:3135209
    _Debug_LogError_m3852() WebGL.js:3135257
    _NetworkingPeer_DebugReturn_m1365() WebGL.js:2302098
    __ZN23InterfaceActionInvoker2IhP8String_tE6InvokeEjP8TypeInfoPvhS1_() WebGL.js:3362186
    _U3CReceiveLoopU3Ec__Iterator2_MoveNext_m1797() WebGL.js:2334890
    __Z26RuntimeInvoker_Boolean_t35PK10MethodInfoPvPS2_() WebGL.js:3316221
    dynCall_iiii() WebGL.js:3444695
    invoke_iiii() WebGL.js:17130
    __ZN6il2cpp2vm7Runtime6InvokeEPK10MethodInfoPvPS5_PP12Il2CppObject() WebGL.js:83972
    _il2cpp_runtime_invoke() WebGL.js:33237
    __Z20il2cpp_invoke_method21ScriptingMethodIl2CppP15ScriptingObjectP18ScriptingArgumentsPP18ScriptingExceptionb() WebGL.js:720985
    __ZN19ScriptingInvocation6InvokeEPP18ScriptingExceptionb() WebGL.js:825426
    __ZN19ScriptingInvocation6InvokeIbEET_PP18ScriptingExceptionb() WebGL.js:825356
    __ZN9Coroutine3RunEv() WebGL.js:816212
    __ZN9Coroutine17ContinueCoroutineEP6ObjectPv() WebGL.js:816160
    __ZN18DelayedCallManager6UpdateEi() WebGL.js:700048
    __Z10PlayerLoopbbP10IHookEvent() WebGL.js:803218
    __ZL8MainLoopv() WebGL.js:1734870
    dynCall_v() WebGL.js:3444506
    Runtime.dynCall() WebGL.js:312
    Browser_mainLoop_runner/<() WebGL.js:9538
    Browser.mainLoop.runIter() WebGL.js:11099
    Browser_mainLoop_runner()
  • So maybe the solution is the same as for initial topic issue?
  • I don't send any special data to new client.
    So I don't have any data that I can split or something like that.

    I tried to optimize my game to send as low data as I can, but it did not help.

    Once again, this game works very well on the other platforms, even on low-end mobile devices.

    Did you have any logs on your servers ?
    Is it possible to know the exact cause of this problem?
  • For anyone experiencing this issue => Exiting receive thread (inside loop). Server: XXXXX

    Here is the solutions that have worked for our team:

    1. Check to see if the scene that you are loading is not MASSIVE in size.
    2. Check to see if the scene being loaded is not sending/receiving data in the first frame (Wait a while before sending/receiving sync information with Photon).

    TO TEST AND SEE IF THIS IS THE CASE:

    1. Create a FULLY EMPTY dummy scene in unity and add it to the build settings
    2. Connect to Photon and try and use that EMPTY scene to see if works (Which it most likely should). This will alert you that your issue lies in the scene you were trying to load (Due to one of the above items OR something else in that specific scene).

    Hope the above solution helps out others going through the same issues!

    Nav Gupta => Former Unity 3D Live Help Expert Team Member and now Founder and CEO of Chaarmi Worlds Inc. making the future metaverse!! Check us out at Chaarmi.com!