{"record":{"id":"15044d13484c042a","repo":"egametang/ET","slug":"service-discovery-agent-response-error-request","errorCode":null,"errorMessage":"service discovery agent response error, request: {requestName}, error: {error}, message: {message}","messagePattern":"service discovery agent response error, request: (.+?), error: (.+?), message: (.+?)","errorType":"exception","errorClass":"RpcException","httpStatus":null,"severity":"error","filePath":"Packages/cn.etetet.servicediscovery/Scripts/Hotfix/Server/ServiceDiscoveryProxySystem.cs","lineNumber":274,"sourceCode":"            }\n\n            IResponse rawResponse = await self.ProcessInnerSender.Call(self.AgentFiberInstanceId, request);\n            if (rawResponse is not T response)\n            {\n                (rawResponse as MessageObject)?.Dispose();\n                throw new Exception(\n                    $\"service discovery agent response type mismatch, request: {requestName}, actual: {rawResponse?.GetType().Name}\");\n            }\n\n            if (response.Error != ErrorCode.ERR_Success)\n            {\n                int error = response.Error;\n                string message = response.Message;\n                if (response is MessageObject messageObject)\n                {\n                    messageObject.Dispose();\n                }\n                throw new RpcException(error,\n                    $\"service discovery agent response error, request: {requestName}, error: {error}, message: {message}\");\n            }\n\n            return response;\n        }\n\n        public static async ETTask<ActorId> ResolveServiceActorIdByRouteKeyAsync(this ServiceDiscoveryProxy self, int sceneType,\n            long routeKey = 0)\n        {\n            EntityRef<ServiceDiscoveryProxy> selfRef = self;\n            string sceneTypeName = SceneTypeSingleton.Instance.GetSceneName(sceneType);\n            if (string.IsNullOrWhiteSpace(sceneTypeName))\n            {\n                throw new ArgumentException($\"resolve service invalid sceneType: {sceneType}\");\n            }\n\n            int retryCount = 0;\n            while (true)","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.servicediscovery/Scripts/Hotfix/Server/ServiceDiscoveryProxySystem.cs#L256-L292","documentation":"RpcException thrown at line 274 in ServiceDiscoveryProxySystem.ForwardToDiscoveryByFailover: the proxy forwarded a request to the agent (ProcessInnerSender.Call to AgentFiberInstanceId) and the agent returned a response with Error != ERR_Success. The error code/message are wrapped and thrown to the proxy's caller. This propagates an application-level error from the discovery agent (which itself may have received it from the master).","triggerScenarios":"A proxy scene calls ForwardToDiscoveryByFailover (subscribe/unsubscribe/discovery queries) and the agent returns a non-success error — typically because the agent's own ForwardToDiscoveryByFailoverCore returned an error (master rejected the request, master unavailable, persistence failure).","commonSituations":"Master unavailable or follower-rejected when the proxy issues a discovery request; DB failure during a subscribe/persist operation; invalid arguments in the proxy request; the agent fiber could not reach the master.","solutions":["Inspect the RpcException error code to determine whether it is master-unavailable (re-resolve), persistence (DB), or invalid-argument (fix payload).","Ensure the agent fiber and master are healthy and reachable.","Retry idempotent proxy operations (subscribe) on master-unavailable/follower-rejected codes."],"exampleFix":"// before\nvar resp = await proxy.ForwardToDiscoveryByFailover<T>(req, name);\n\n// after\ncatch (RpcException e) when (ServiceDiscoveryErrorHelper.ShouldTriggerFailover(e.Error))\n{\n    // transient master-side issue; retry the proxy call after a short delay\n}","handlingStrategy":"try-catch","validationCode":"// Verify the agent fiber instance is set before forwarding from the proxy.\nif (proxy == null || proxy.AgentFiberInstanceId == default)\n{\n    Log.Warning(\"proxy agent fiber not initialized; cannot forward\");\n    return;\n}","typeGuard":null,"tryCatchPattern":"catch (RpcException e)\n{\n    if (ServiceDiscoveryErrorHelper.ShouldTriggerFailover(e.Error))\n    {\n        // transient master-side issue; retry idempotent proxy operations after delay\n    }\n    else\n    {\n        Log.Error($\"discovery proxy forward failed {e.Error}: {e.Message}\");\n    }\n}","preventionTips":["Keep the agent fiber and master healthy so proxy forwards succeed.","Retry idempotent proxy operations on failover-eligible codes.","Inspect the propagated error code to find the upstream root cause."],"tags":["csharp","et-framework","service-discovery","rpc","proxy","master-election","database"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}