egametang/ET · error · RpcException

service discovery response error, request: {requestName}, er

Error message

service discovery response error, request: {requestName}, error: {error}, message: {message}

What it means

RpcException thrown at line 640 in ForwardToDiscoveryByFailoverCore: the master returned a response with response.Error != ERR_Success. The error code and message from the response are wrapped into an RpcException and propagated. The actual error code comes from the master's handler (e.g. ERR_ServiceDiscoveryInvalidArgument, ERR_ServiceDiscoveryPersistenceFailed, ERR_ServiceDiscoveryFollowerRejected).

Source

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

                        throw new Exception("service discovery agent disposed");
                    }

                    if (rawResponse is not T response)
                    {
                        (rawResponse as MessageObject)?.Dispose();
                        throw new Exception(
                            $"service discovery response type mismatch, request: {requestName}, actual: {rawResponse?.GetType().Name}");
                    }

                    if (response.Error != ErrorCode.ERR_Success)
                    {
                        int error = response.Error;
                        string message = response.Message;
                        if (response is MessageObject messageObject)
                        {
                            messageObject.Dispose();
                        }
                        throw new RpcException(error,
                            $"service discovery response error, request: {requestName}, error: {error}, message: {message}");
                    }

                    return response;
                }
                catch (Exception e)
                {
                    self = selfRef;
                    if (self == null)
                    {
                        throw;
                    }

                    bool shouldResolveMaster = self.ShouldResolveMasterAfterFailure(e);
                    if (shouldResolveMaster)
                    {
                        self.InvalidateEndpointAndTriggerBackgroundRegister("call-failure");
                    }

View on GitHub (pinned to 5cab01f7a8)

Solutions

  1. Inspect the wrapped error code in the RpcException to identify the root cause (follower rejection -> re-resolve master; persistence -> check DB; invalid argument -> fix payload).
  2. For follower-rejection/master-unavailable, allow the failover loop to re-resolve and retry.
  3. For persistence errors, verify DB connectivity and capacity.
  4. For invalid-argument errors, validate the request before forwarding.

Example fix

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

// after
catch (RpcException e) when (e.Error == ErrorCode.ERR_ServiceDiscoveryFollowerRejected)
{
    // master moved; the loop already invalidates and retries; surface to caller if exhausted
}
catch (RpcException e) when (e.Error == ErrorCode.ERR_ServiceDiscoveryPersistenceFailed)
{
    // check DB health
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Validate request payload before forwarding to avoid invalid-argument errors.
if (!ServiceDiscoveryHelper.TryValidateRequiredActorId(req.AgentActorId, nameof(req), nameof(req.AgentActorId), out _))
{
    return; // fix payload instead of forwarding
}

Try / catch

catch (RpcException e)
{
    switch (e.Error)
    {
        case ErrorCode.ERR_ServiceDiscoveryFollowerRejected:
        case ErrorCode.ERR_ServiceDiscoveryMasterUnavailable:
            // let failover re-resolve; retry at higher level if exhausted
            break;
        case ErrorCode.ERR_ServiceDiscoveryPersistenceFailed:
            Log.Error($"discovery DB failure: {e.Message}");
            break;
        default:
            Log.Error($"discovery response error {e.Error}: {e.Message}");
            break;
    }
}

Prevention

When it happens

Trigger: The forwarded request reached the master but the master rejected it: invalid arguments, persistence (DB) failure, follower rejection (the node is not the master), or operation failure. ShouldResolveMasterAfterFailure decides whether to failover based on the code.

Common situations: The agent contacted a stale master that is now a follower (ERR_ServiceDiscoveryFollowerRejected); the DB write behind the master failed (ERR_ServiceDiscoveryPersistenceFailed); the request payload failed validation (ERR_ServiceDiscoveryInvalidArgument); the target master scene errored internally.

Related errors


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