This document is about: FUSION 2
SWITCH TO

Analyzing Disconnects

當您建立一個在線多人遊戲時,您必須意識到,有時客戶端和伺服器之間的連接會失敗。

斷線可能是由軟件或硬件造成的。
如果連接的任何一個環節出現故障,信息會被延遲、丟失或損壞,連接需要被關閉。

如果這種情況經常發生,您可以做一些處理。

斷開連接的原因

還有一些情況是客戶端根本無法連接(例如,伺服器無法索取,伺服器地址不適當,沒有DNS可用,自主持的伺服器沒有啟動,等等)。 在這種情況下,這些不被視為斷開連接,而是 '(初始)連接失敗'。

客戶端SDK提供斷開連接的回調和斷開連接的原因。
使用這些來調查您所遇到的意外斷開連接的情況。
這裡我們列出了主要的斷開原因,以及它們是在客戶端還是在伺服器端造成。

由客戶端引起的斷開連接

  • 客戶端超時:沒有/過晚收到伺服器的ACK。詳情見"超時斷連"。
  • 客戶端套接字異常(連接遺失)。
  • 客戶端連接在接收時失敗(緩沖區滿,連接遺失)。參見"流量問題和緩沖區滿"。
  • 客戶端連接在發送時失敗(緩沖區滿,連接遺失)。參見"流量問題和緩沖區滿"。

由伺服器斷開連接

  • 伺服器端超時:沒有/過晚收到客戶端的ACK。詳情見"超時斷開連接"。
  • 伺服器發送的緩沖區滿了(訊息過多)。參見"流量問題和緩沖區滿"。
  • 許可証或訂閱CCU限制被擊中。

超時斷開連接

Unlike plain UDP, Photon's reliable UDP protocol establishes a connection between server and clients:
Commands within a UDP package have sequence numbers and a flag if they are reliable.
If so, the receiving end has to acknowledge the command.
Reliable commands are repeated in short intervals until an acknowledgement arrives.
If it does not arrive, the connection is timed out.

Both sides monitor this connection independently from their perspective.
Both sides have their rules to decide if the other is still available.

If a timeout is detected, a disconnect happens on that side of the connection.
As soon as one side thinks the other side does not respond anymore, no message is sent to it.
This is why timeout disconnects are one sided and not synchronous.

Back to top