Desuq Cafe

Back to Devlog
Host Migration Networking Architecture

FishNet Host Migration System

The Problem

FishNet doesn’t support host migration natively. In a P2P game, if the host disconnects — whether they leave gracefully or their connection drops — everyone loses the session. All game state gone. For a co-op RPG where you might be mid-boss-fight, that’s not acceptable.

What I Built

A full host migration system that handles both scenarios:

  • Graceful Handoff — host wants to leave, triggers a clean transfer with ACK confirmation. Ping-based selection picks the best candidate.
  • Crash Recovery — host disappears unexpectedly, the system detects the disconnect and automatically migrates to a new host.

State Preservation

The core challenge was making sure nothing gets lost during migration. The system serializes and restores:

  • All SyncVar types (primitives, Unity types like Vector3/Quaternion/Color, enums, arrays)
  • SyncList, SyncDictionary, SyncHashSet collections
  • Physics state (Rigidbody velocity, drag, gravity, constraints)
  • Nested NetworkObject parent-child relationships
  • NetworkObject references with ID remapping

Server-owned objects like enemies and NPCs get respawned by the new host with their state intact.

Architecture

Built around a MigratableNetworkBehaviour base class that replaces the standard NetworkBehaviour. It provides OnStartServerFresh() for initial spawns and OnStartServerRestored() for post-migration, plus custom serialization hooks via OnMigrationSerialize/OnMigrationDeserialize for anything beyond SyncVars.

Delta snapshots with GZip compression keep bandwidth reasonable — only changed objects get broadcast. The whole migration runs through a state machine with abort/retry logic for robustness.

Status

Working in an isolated test project, not yet integrated into Inhyeong. The main thing left is testing edge cases under real network conditions.

Other posts