{"record":{"id":"5a2171af027fc6d8","repo":"egametang/ET","slug":"default-conn-throw-exception-channelid","errorCode":null,"errorMessage":"default conn throw Exception! {channelId}","messagePattern":"default conn throw Exception! (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"Packages/cn.etetet.core/Scripts/Core/Share/Network/AService.cs","lineNumber":83,"sourceCode":"            this.Id = 0;\n        }\n\n        public abstract void Update();\n\n        public abstract void Remove(long id, int error = 0);\n\n        public bool IsDisposed()\n        {\n            return this.Id == 0;\n        }\n        \n        public abstract void Create(long id, IPEndPoint ipEndPoint);\n\n        public abstract void Send(long channelId, MemoryBuffer memoryBuffer);\n\n        public virtual (uint, uint) GetChannelConn(long channelId)\n        {\n            throw new Exception($\"default conn throw Exception! {channelId}\");\n        }\n        \n        public virtual void ChangeAddress(long channelId, IPEndPoint ipEndPoint)\n        {\n        }\n    }\n}","sourceCodeStart":65,"sourceCodeEnd":90,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.core/Scripts/Core/Share/Network/AService.cs#L65-L90","documentation":"AService.GetChannelConn is a virtual method whose base implementation throws, signalling that the default service does not track per-channel connection ids. Only KCP-style services override it to return (LocalConn, RemoteConn); calling it on a base or non-KCP service is a contract violation.","triggerScenarios":"Holding an AService reference (not the concrete KService) and calling GetChannelConn on a TCP/websocket service that never overrode it, or on a custom AService subclass that forgot the override.","commonSituations":"New AService implementation not yet implementing conn tracking, or generic code that assumes all services support GetChannelConn.","solutions":["Call GetChannelConn only on services known to override it (KService).","If you author an AService subclass that needs conn ids, override GetChannelConn.","Check the concrete service type before invoking."],"exampleFix":"// before\n(uint l, uint r) = anyService.GetChannelConn(channelId);\n// after\nif (service is KService kService)\n    (uint l, uint r) = kService.GetChannelConn(channelId);","handlingStrategy":"type-guard","validationCode":"null","typeGuard":"public static bool SupportsGetChannelConn(AService s) => s is KService;","tryCatchPattern":"null","preventionTips":["Program against the concrete service type when you need conn ids.","Document which AService subclasses override GetChannelConn.","Add a virtual default that returns a sentinel instead of throwing if a softer contract is acceptable."],"tags":["network","abstraction","csharp"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}