egametang/ET · error · RpcException

ERR_ServiceDiscoveryMasterUnavailable

ERR_ServiceDiscoveryMasterUnavailable

Error message

service discovery agent not ready, request: {requestName}, scene: {self.Root().Name}

What it means

RpcException with code ERR_ServiceDiscoveryMasterUnavailable, thrown at line 452 after EnsureReadyForRequestAsync exhausted all 30 resolve retries while the agent was still alive. It means the agent could not discover/register with any service-discovery master within MasterResolveMaxRetryCountWhenEndpointUnavailable iterations, so the request cannot be forwarded. This is the canonical 'master unreachable' failure surfaced to callers.

Source

Thrown at Packages/cn.etetet.servicediscovery/Scripts/Hotfix/Server/ServiceDiscoveryAgentSystem.cs:452

                if (self.IsReady())
                {
                    return;
                }

                if (retry + 1 < totalRetryCount)
                {
                    int delay = GetMasterResolveRetryDelay(retry);
                    await self.Root().TimerComponent.WaitAsync(delay);
                }
            }

            self = selfRef;
            if (self == null)
            {
                throw new Exception("service discovery agent disposed");
            }

            throw new RpcException(ErrorCode.ERR_ServiceDiscoveryMasterUnavailable,
                $"service discovery agent not ready, request: {requestName}, scene: {self.Root().Name}");
        }

        private static async ETTask TryLoadActiveMasterFromDbAsync(this ServiceDiscoveryAgent self)
        {
            if (self == null)
            {
                return;
            }

            EntityRef<ServiceDiscoveryAgent> selfRef = self;
            Scene root = self.Root();
            string rootName = root.Name;
            DBManagerComponent dbManagerComponent = root.GetComponent<DBManagerComponent>();
            if (dbManagerComponent == null)
            {
                return;
            }

View on GitHub (pinned to 5cab01f7a8)

Solutions

  1. Confirm the service-discovery master scene is running and its ActorId is published in ServiceDiscoveryBootstrapSingleton.
  2. Check master election/lease health and that the master's heartbeat renews the lease before expiry.
  3. Verify network connectivity and ActorMessage routing between the agent fiber and master fiber.
  4. If using DB-backed master recovery, ensure the DB is reachable and the master record collection is correct.
  5. Fix startup ordering so the master is elected before scenes issue discovery requests.

Example fix

// before
var resp = await agent.ForwardToDiscoveryByFailover<T>(req, name);

// after
if (!agent.IsReady())
{
    Log.Warning($"discovery not ready, queuing/skipping {name}");
    return default; // or retry at a higher level
}
var resp = await agent.ForwardToDiscoveryByFailover<T>(req, name);
Defensive patterns

Strategy: retry

Validate before calling

public static bool IsDiscoveryReady(ServiceDiscoveryAgent agent)
{
    return agent != null && agent.IsReady();
}

if (!IsDiscoveryReady(agent))
{
    // master not up; do not attempt forwarding yet
}

Try / catch

catch (RpcException e) when (e.Error == ErrorCode.ERR_ServiceDiscoveryMasterUnavailable)
{
    // master unreachable after retries; degrade gracefully / queue / alert
    Log.Error($"discovery master unavailable: {e.Message}");
}

Prevention

When it happens

Trigger: ForwardToDiscoveryByFailover is called but the master endpoint is not bootstrapped (ServiceDiscoveryBootstrapSingleton.MasterActorId is default), the master scene is down, the master lease expired, or every register attempt failed. The loop calls TriggerBackgroundRegister and waits, but IsReady() (ServiceDiscoveryActorId set AND AgentRegistered status) never becomes true.

Common situations: Master scene not started or wrong scene-type configured; network partition between agent fiber and master fiber; master crashed and lease not renewed / not re-elected; DB unavailable so TryLoadActiveMasterFromDbAsync cannot recover the master record; startup ordering where dependent scenes start before the discovery master.

Related errors


AI-assisted analysis of egametang/ET@5cab01f7a8 (2026-08-13). Data as JSON: /api/errors/4f90d975d62b2abe. Report an issue: GitHub.