Trying to understand disconnection

Options
I'm using the debug build of Photon3Unity3D.dll (v3.0.1.14) and a custom local server.

If I enable simulation on the client, with default values (100ms latency and 1% packet loss), then I have a very hard time getting in to the game. The client can connect OK, but it only takes a few seconds to get disconnected after that.

The client reports a lot of "Resending command" messages on the same frame, which seems strange. It also tries to resend commands after disconnecting. Is this just a side effect of the simulation queue?

The redundant commands recieved on frame 1137 kind of make sense because the client fails to ack for a bit while it loads. But it seems like that short period of time with those few missing ACKS is what's causing the disconnect even though the server's disconnect timeout is set to 30 seconds.
(INFO) FRAME 1137: Peer.Service: Connected
(INFO) FRAME 1137: DebugReturn (INFO):Info: command was received before! Old/New: NC(0|6 r/u: 16/0 st/r#/rt:0/0/0)/NC(0|6 r/u: 16/0 st/r#/rt:0/0/0) inReliableSeq#: 2
(INFO) FRAME 1137: DebugReturn (INFO):Info: command was received before! Old/New: NC(0|6 r/u: 17/0 st/r#/rt:0/0/0)/NC(0|6 r/u: 17/0 st/r#/rt:0/0/0) inReliableSeq#: 2
(INFO) FRAME 1137: DebugReturn (INFO):Info: command was received before! Old/New: NC(0|6 r/u: 18/0 st/r#/rt:0/0/0)/NC(0|6 r/u: 18/0 st/r#/rt:0/0/0) inReliableSeq#: 2
(INFO) FRAME 1137: DebugReturn (INFO):Info: command was received before! Old/New: NC(0|6 r/u: 19/0 st/r#/rt:0/0/0)/NC(0|6 r/u: 19/0 st/r#/rt:0/0/0) inReliableSeq#: 2
(INFO) FRAME 1137: DebugReturn (INFO):Info: command was received before! Old/New: NC(0|6 r/u: 20/0 st/r#/rt:0/0/0)/NC(0|6 r/u: 20/0 st/r#/rt:0/0/0) inReliableSeq#: 2
(INFO) FRAME 1137: DebugReturn (INFO):Info: command was received before! Old/New: NC(0|6 r/u: 21/0 st/r#/rt:0/0/0)/NC(0|6 r/u: 21/0 st/r#/rt:0/0/0) inReliableSeq#: 2
(INFO) FRAME 1138: Peer.Service: WorldEntered
(INFO) FRAME 1139: Peer.Service: WorldEntered
(INFO) FRAME 1140: Peer.Service: WorldEntered
(INFO) FRAME 1141: Peer.Service: WorldEntered
(INFO) FRAME 1142: Peer.Service: WorldEntered
(INFO) FRAME 1143: Peer.Service: WorldEntered
(INFO) FRAME 1144: Peer.Service: WorldEntered
(INFO) FRAME 1145: Peer.Service: WorldEntered
(INFO) FRAME 1146: Peer.Service: WorldEntered
(INFO) FRAME 1147: Peer.Service: WorldEntered
(INFO) FRAME 1148: Peer.Service: WorldEntered
(INFO) FRAME 1149: Peer.Service: WorldEntered
(INFO) FRAME 1150: Peer.Service: WorldEntered
(INFO) FRAME 1150: DebugReturn (INFO):Server sent disconnect. PeerId: 15 RTT/Variance:203/24
(INFO) FRAME 1150: Peer Status Changed: StateStrategy(Photon.MmoDemo.Client.GameStateStrategies.WorldEntered) StatusCode(DisconnectByServer)
(INFO) FRAME 1150: DebugReturn (INFO):StopConnection()
(INFO) FRAME 1150: DebugReturn (INFO):Resending command: NC(0|6 r/u: 4/0 st/r#/rt:10062/1/20062). times out: 299 now: 10374
(INFO) FRAME 1150: DebugReturn (INFO):Resending command: NC(0|6 r/u: 5/0 st/r#/rt:10062/1/20062). times out: 299 now: 10374
(INFO) FRAME 1150: DebugReturn (INFO):Resending command: NC(0|6 r/u: 6/0 st/r#/rt:10062/1/20062). times out: 299 now: 10374
(INFO) FRAME 1150: DebugReturn (INFO):Resending command: NC(0|6 r/u: 7/0 st/r#/rt:10062/1/20062). times out: 299 now: 10374
(INFO) FRAME 1150: DebugReturn (INFO):Resending command: NC(0|6 r/u: 8/0 st/r#/rt:10062/1/20062). times out: 299 now: 10374
(INFO) FRAME 1150: DebugReturn (INFO):Resending command: NC(0|6 r/u: 9/0 st/r#/rt:10062/1/20062). times out: 299 now: 10374
(INFO) FRAME 1150: DebugReturn (INFO):Resending command: NC(0|6 r/u: 10/0 st/r#/rt:10062/1/20062). times out: 299 now: 10374
(INFO) FRAME 1150: DebugReturn (INFO):Resending command: NC(0|6 r/u: 11/0 st/r#/rt:10062/1/20062). times out: 299 now: 10374
(INFO) FRAME 1150: DebugReturn (INFO):Resending command: NC(0|6 r/u: 12/0 st/r#/rt:10062/1/20062). times out: 299 now: 10374
(INFO) FRAME 1150: DebugReturn (INFO):Resending command: NC(0|6 r/u: 13/0 st/r#/rt:10062/1/20062). times out: 299 now: 10374
(INFO) FRAME 1150: DebugReturn (INFO):Resending command: NC(0|6 r/u: 14/0 st/r#/rt:10062/1/20062). times out: 299 now: 10374

Here is the server config:
EnablePerformanceCounters="true"
MaxMessageSize="512000"
MaxQueuedDataPerPeer="512000"
PerPeerMaxReliableDataInTransit="65536"
PerPeerTransmitRateLimitKBSec="256"
PerPeerTransmitRatePeriodMilliseconds="200"
MinimumTimeout="60000"
MaximumTimeout="60000"
DataSendingDelayMilliseconds="5"
AckSendingDelayMilliseconds="5"
MinimumRetransmitTimeout="0"
ProduceDumps="true">

What do you think is causing the server to disconnect this client? Is it just because of the simulation being enabled? When we play on a live server that has 100ms latency (but less packet loss, typically), then we don't have disconnection problems. But on low-end machines that spend a lot of time blocked inside unity's asset functions tend to get disconnected very easily, even if simulation is disabled and the release build of the dll is used.

Comments

  • To be clear, when I say "a lot of time blocked in unity's asset functions", I'm talking about a few hundred milliseconds to a couple of seconds.
  • Tobias
    Options
    The timeout of server and client are independent of each other, so a server setting of 30sec doesn't change anything client side.
    Client side, the timeout is controlled by PhotonPeer values DisconnectTimeout and SentCountAllowance.

    While you are loading assets in Unity, you should run a thread to call SendOutgoingCommands. Unity won't call Update() while it's loading. The thread keeps your connection up and prevents re-sends by the server.

    I will have to check why the disconnect is still followed by re-sends. This looks suspicious.
    I'm not too sure why the server times you out faster than you anticipate. In some cases, a command gets lost early on and everything still looks ok while you load and do other stuff. Still, that lost command triggers a few repeats and ultimately times out the connection.