Disconnections and TCP

salva
salva
Hi,

We're using PUN with Unity on mobile, and we having problems with disconnections issues. During gameplay, on old devices, (sometimes due gc) game loop freezes more than 100ms. According your docs, it can be a possible cause.
Switching to TCP can improve this? how i can change default UDP to TCP protocol on PUN in Unity?

Thanks.

Comments

  • 100ms are not a problem by themselves. There is likely more to this than that.

    A switch to TCP is not the cure-all for this type of problems and I would prefer you to check if you can't optimize your game just some more so that it works on the targeted devices, too.

    Unlike UDP, TCP can't send anything without acknowledgements. If there is a hiccup in the connection, everything has to wait until all of the data was transferred completely. With unreliable messages, UDP is able to skip a few outdated updates and catch up to the latest info.

    Do you see potential to save traffic or memory?
    Did you make use of the profiler yet?
    Do you instantiate a lot of GameObjects with PhotonViews? If there are a lot, you could try what happens when you set PhotonNetwork.UsePrefabCache = false on those clients. It could conserve some memory.

    If all else breaks, you can switch to TCP, of course.
  • See PhotonNetwork.SwitchToProtocol(ConnectionProtocol cp) and read the doc carefully. You will have to switch the port, too.
  • We're not instantiating network objects, we use only rpc calls because our game doesn't need to send every state change, only selected ones... so not too much traffic are generated.
    Only 2 PhotonView components on scene receiving rpc calls.
    On our test devices, doesn't occur but on production i can see a lot of disconnections events.
    i will try to reproduce it with profiler active to obtain more info and/or switch to tcp to see any changes.

    Note that we're already using PhotonChat concurrently. I suppose that isn't a problem.

    Thanks.
    Tobias wrote:
    100ms are not a problem by themselves. There is likely more to this than that.

    A switch to TCP is not the cure-all for this type of problems and I would prefer you to check if you can't optimize your game just some more so that it works on the targeted devices, too.

    Unlike UDP, TCP can't send anything without acknowledgements. If there is a hiccup in the connection, everything has to wait until all of the data was transferred completely. With unreliable messages, UDP is able to skip a few outdated updates and catch up to the latest info.

    Do you see potential to save traffic or memory?
    Did you make use of the profiler yet?
    Do you instantiate a lot of GameObjects with PhotonViews? If there are a lot, you could try what happens when you set PhotonNetwork.UsePrefabCache = false on those clients. It could conserve some memory.

    If all else breaks, you can switch to TCP, of course.
  • It's not necessarily the number of PhotonViews that can cause a disconnect.
    It can also be the amount of data you send. You could have a look at the PhotonStatsGUI. Maybe it shows a lot of bytes/sec being sent or a lot of messages/sec.
    It can also be a wireless router that doesn't work well with some mobiles. In our office, my Phone has constant disconnects on a specific router but not on the other. Different phones are fine yet again on the same hardware.

    I don't want to discourage you but I want to point out: We need to know more.
    Are you using the Cloud? Is your app registered with the email you use in this forum? Then we can have a look at the counters.
  • Hi,

    The email is on your pm.
    After simulating low connection PUN fired "Queue Incoming Reliable Warning", and i confirmed that all rpc are sended as "OthersBuffered". Changing it to Others seems solve the problem (I don't need it).

    Thanks.
  • Ok, good this got solved.
    The buffer is really not needed.