Server TimeoutDisconnect when in Unity Editor Mode

Options
Hi all,

Is there a way to get around the server timeout disconnects when working/testing in Unity's editor mode ?

I'm running a custom photon server and all's going good generally when i'm running via a desktop or web build of the client. However, when running through in editor mode the scene changes via loadlevel always grind through and this causes the server to disconnect the client due to a timeout. The only bits i've seen for the timeouts relate to running PUN or using the LoadBalancing application and with it being in editor mode everything freezes during the swap.

Does anyone have a work around for this or a pointer in the right direction ?

Cheers in advance.

Comments

  • ...this causes the server to disconnect the client due to a timeout
    This sounds like an issue within your code/logic, rather than the photon framework producing unwanted results. The timeout mechanic is actually a very useful one, as it helps your server to clean up stranded peers when a peer disconnects for reasons unknown to the server (such as the client forcefully quitting the application). So you don't want to go messing with the timeout values too much.

    Could you provide more information on what it is that you are trying to achieve, and what you have tested so far?
  • srmatthe
    srmatthe
    edited October 2015
    Options
    The build runs fine when it's deployed as either a stand alone or web build, no issue there.

    When it is run through the Unity editor Unity itself causes excessive delays on some scene loads which is then causing the server to time out. The delays are present whether backend code is included or not.

    I agree, that it's not a Photon issue but believe it's a Unity issue with running in the editor.

    Reading through the Analysing Disconnects documentation there's mentions in there regarding LoadBalancing and PUN from stalling the message queue during scene loads through to calling Service() regularly and changing reliable retries etc. but these aren't useful when it comes to running in Editor mode. Unity itself seems to hang so I was wondering if anyone had used a workaround that worked for them within Unity Editor. Even something as simple as to tell Photon to not expect anything from this client or disconnect them until a trigger is sent to say it's "all ok". This is only something i'll be using during development as there's no issues in a live environment. I don't fancy having to make a build after every code change during the dev.

    There's very little information out there about the Server version as it all seems geared to the cloud API instances or PUN.
  • Hmm, yeah that sounds very odd. It does sound though that there is something during the loading of your level that is causing the issue, so it sounds as if you are on the right track.

    Again, avoid looking for "workarounds". You have found an issue, the aim now should be to solve the issue. With the information you've provided, here's what I would suggest to try out next:
    - firstly, make sure you are aware and understand how to debug both your client and server code. There are two main ways to do this. The more complex of the two is to set up Visual Studio to debug your server code (there's a good post within this forum on how to do that). The second of the two is to use Photon's logger. You can find information on this here: https://doc.photonengine.com/en/onpremise/current/reference/logging. Debug everywhere, and log everything.
    - Service() is a method that is called on the client-side, by a PhotonPeer object (or an object that inherits from this). You will need to locate where this method is being called within your client scripts, and look at maybe halting the calling of this method during a level switch. Alternatively, PhotonPeer objects can disable incoming and outgoing communications, I think (if I remember correctly) by calling the PhotonPeer's DisableOutgoing/IncommingCommands. When you do this, calling Service() will have no effect.

    Doing the above should hopefully point you in the right direction.
  • srmatthe
    Options
    The occurrence is a known Unity issue and has been for a long time.

    No probs on the debugging, i've been programming for a fair few years now but this is my first foray into Photon and it's minimal documentation :0)

    Workaround was probably the wrong word to use but either way I managed a solution. I dug into the PUN code to see what was going on when ismessagequeuerunning is used to stall between scene loads. I replicated the SupportClass call to start a background thread which just sent ACK's back to the server while the main thread hangs doing the load. Called that inside the new SceneLoader, re-enabled once the scene was loaded and all is working fine.

    Cheers,
  • this is my first foray into Photon and it's minimal documentation :0)
    I welcome you to the storm! XD

    That sounds like a pretty solid solution. I had a quick play around with things last night to try and discover more about the issue you were facing, and it appears to be a mixture of things. As we know, Unity runs on one thread (unless you force it to do otherwise). This also means that scripts run within unity also run on unity's main thread. I couldn't work out why it differs from being in editor view to an actual build, but it certainly seems to be the case that during a scene change, things can pile up on that single thread very quickly, especially when you are making many service calls per second. So you are right to solve the issue with multi-threading.

    Good luck with your game!