How does SetTimeout work ?

Options
As I have connection timeout from time to time, I've tried to set a biggest timeout but I keep getting timeout, when I call getTimeout, I got the correct value that I set, but It feels like this value is not used as I've seen no change in the timeout that I get. Maybe this as nothing to do with my timeout and it comes from somewhere else.

Here is my error log
2019-09-24 09:53:08,045 INFO enetpeer.cpp ExitGames::Photon::Internal::EnetPeer::execute() 1147 Info: Server sent disconnect because of a timeout. PeerId: 12054 RTT/Variance: 101/151
connectionErrorReturn
received connection error 1041

Comments

  • Kaiserludi
    Options
    Hi @benjaml.

    Photon has two timeout settings: A client side timeout and a server side timeout.
    On the client you can set the timeout time and the max resents amount and when the client does not receive an acknowledgement by the server for receiving a reliable message within this time and within the max amount of resents (whichever of these two limits gets hit first), then it will consider the connection to be lost.
    On the server there is a minimum and a maximum timeout and the server MIGHT consider the connection to be lost when it does not receive an acknowledgement by the client for receiving a reliable message within the minimum timeout and it WILL consider the connection lost when it does not receive it within the maximum timeout. These timeout values can be configured in the servers config file.

    The log message tells you that you got a server side timeout, not a client side one. Changing the values for the client side timeout does not have an influence on how soon you get a server side timeout.

    On Photon Public and Premium Cloud the server side minimum and maximum timeout values are 5 and 10 seconds and can't be changed (because they are a per server machine setting and Photon Public and Premium Cloud are shared environments, so that the setting affects all users, not just you).
    On Photon Enterprise Cloud and on self-hosted Photon server instances you can configure these settings yourself.

    If the timeouts happens during debugging, because of breakpoints in the debugger, then I suggest to simply connect to a self.hosted Photon server instance that runs on your local development machine when you need the connection to stay alive while the clients execution is paused by a breakpoint for extended amounts of time.

    Please see https://doc.photonengine.com/en-us/server/current/getting-started/photon-server-in-5min for instructions on how to run a self-hosted Photon server instance.

    Please note that when you wan to connect to a self-hosted server-instance, you need to pass not only the servers address, but also ServerType::MASTER_SERVER to Client::connect(), while for connections to Photon Cloud you need to pass ServerType::NAME_SERVER (the latter is the default value that gets used when you don't pass anything for that parameter).

    Last but not least: Obviously when using a local server during development, you should at least sometimes run against a remote server like i.e. Photon Cloud to be sure that your game code behaves well when there is relevant latency.