egametang/ET · warning · RpcException

ERR_ServiceNotFound

ERR_ServiceNotFound

Error message

route service not found in local cache sceneType: {sceneTypeName}

What it means

RpcException with code ERR_ServiceNotFound thrown at line 410 in ResolveServiceActorIdByRouteKeyOnce: the proxy's local service cache has zero entries for the requested sceneType. Because no instance is known locally, the route-key selection cannot proceed. ResolveServiceActorIdByRouteKeyAsync wraps this in a retry loop (up to ServiceResolveRetryTimes) with backoff; if still empty, it propagates.

Source

Thrown at Packages/cn.etetet.servicediscovery/Scripts/Hotfix/Server/ServiceDiscoveryProxySystem.cs:410

                    }

                    if (!ShouldRetryServiceCallError(rpcException.Error) || retryCount >= self.ServiceResolveRetryTimes)
                    {
                        throw;
                    }

                    await self.WaitResolveRetryDelayAsync();
                }
            }
        }

        private static ActorId ResolveServiceActorIdByRouteKeyOnce(this ServiceDiscoveryProxy self, int sceneType, string sceneTypeName,
            long routeKey)
        {
            List<ServiceInfo> localServices = self.GetBySceneType(sceneType);
            if (localServices.Count == 0)
            {
                throw new RpcException(ErrorCode.ERR_ServiceNotFound,
                    $"route service not found in local cache sceneType: {sceneTypeName}");
            }

            return SelectServiceActorIdByRouteKey(localServices, routeKey, sceneTypeName);
        }

        private static bool ShouldRetryResolveService(this ServiceDiscoveryProxy self, RpcException rpcException)
        {
            return rpcException.Error == ErrorCode.ERR_ServiceNotFound
                   || ServiceDiscoveryErrorHelper.ShouldTriggerFailover(rpcException.Error);
        }

        private static bool ShouldRetryServiceCallError(int error)
        {
            return error == ErrorCode.ERR_ServiceNotFound
                   || ServiceDiscoveryErrorHelper.ShouldTriggerFailover(error);
        }

View on GitHub (pinned to 5cab01f7a8)

Solutions

  1. Ensure the target service scene is running and has registered with discovery before resolving.
  2. Confirm the proxy has subscribed to the sceneType and its local cache is populated (check subscribe/refresh timing).
  3. Verify the sceneType argument maps to a real registered scene (SceneTypeSingleton.Instance.GetSceneName).
  4. Delay/queue the resolve until discovery notifies the proxy that services for the sceneType exist.

Example fix

// before
ActorId id = await proxy.ResolveServiceActorIdByRouteKeyAsync(sceneType, routeKey);

// after: ensure cache is populated, then resolve
if (proxy.GetBySceneType(sceneType).Count == 0)
{
    await proxy.SubscribeServiceChangeAsync(/* filter for sceneType */);
    // optionally wait for notification
}
ActorId id = await proxy.ResolveServiceActorIdByRouteKeyAsync(sceneType, routeKey);
Defensive patterns

Strategy: validation

Validate before calling

// Ensure the proxy has at least one cached instance before resolving.
List<ServiceInfo> services = proxy.GetBySceneType(sceneType);
if (services.Count == 0)
{
    // subscribe/refresh first, then resolve
    await proxy.SubscribeServiceChangeAsync(BuildFilterForSceneType(sceneType));
    services = proxy.GetBySceneType(sceneType);
    if (services.Count == 0)
    {
        Log.Warning($"no service registered for sceneType {sceneType}");
        return default;
    }
}

Type guard

public static bool HasCachedService(ServiceDiscoveryProxy proxy, int sceneType)
{
    return proxy != null && proxy.GetBySceneType(sceneType).Count > 0;
}

Try / catch

catch (RpcException e) when (e.Error == ErrorCode.ERR_ServiceNotFound)
{
    // no local instance; subscribe and retry, or degrade
    Log.Warning($"service not found for sceneType {sceneType}: {e.Message}");
}

Prevention

When it happens

Trigger: ResolveServiceActorIdByRouteKeyAsync/CallBySceneTypeAsync is called for a sceneType whose services have not been registered with (or discovered by) this proxy yet — GetBySceneType(sceneType).Count == 0. The proxy must have a subscribed/refreshed local cache containing at least one instance.

Common situations: The target service scene has not started/registered; the proxy has not subscribed to that sceneType or its subscription snapshot is empty/stale; startup ordering where the caller resolves before services publish; the sceneType int is wrong/mismatched so no service matches.

Related errors


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