Skip to content

Python net_sync_manager: Server IP discovered via discovery is not automatically used for sync connection #365

@mhama

Description

@mhama

Python net_sync_manager: Server IP discovered via discovery is not automatically used for sync connection

Summary

In the Python client (net_sync_manager), the server address and port information discovered via UDP server discovery is not automatically passed to the sync connection process. Discovery and connection are completely decoupled, and the integrated "discover → connect" flow that exists on the Unity side is missing.

Current Behavior

In client.py, the _discovery_loop (L1098-1147) only fires the on_server_discovered event when a server is found, with no bridging to the connection process.

A comment at L1131 reads # Could auto-reconnect here if desired, indicating this was intentionally left unimplemented.

Specifically, the following are missing:

  1. Discovered address/ports are not reflected in internal stateself._server, self._dealer_port, self._sub_port remain at the values set in __init__ and are never updated
  2. start() is not automatically called after discovery — The start() method (L271) connects using the internal address/ports, but is never invoked from the discovery flow
  3. Discovery does not auto-stop after finding a server — Even after a server is found, stop_discovery() is not called, and broadcasts continue every 5 seconds
  4. No way to apply discovered address to an existing instance — No setter or method exists to update the address/ports, so users must create a new instance entirely

Comparison with Unity (C#)

On the Unity side, the flow from discovery to connection is fully integrated:

Step Unity (C#) Python
Server found OnServerDiscovered event fired on_server_discovered event fired
Store address Updates _serverAddress, _dealerPort, _subPort Does nothing
Stop discovery Auto-calls StopDiscovery() Does not stop
Start connection Auto-calls ConnectionManager.Connect() Does not connect

Expected Behavior

When a server is found via discovery, the following flow should execute automatically:

  1. Reflect the discovered address and ports in internal state
  2. Stop discovery
  3. Automatically start the sync connection

Relevant Code

  • STYLY-NetSync-Server/src/styly_netsync/client.py
    • _discovery_loop (L1098-1147): Discovery loop
    • start() (L271-318): Connection process
    • on_server_discovered (L201): Event handler (fire only)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions