{"record":{"id":"84b486ba5d323a61","repo":"egametang/ET","slug":"getchannelconn-conn-not-found-kchannel-channelid","errorCode":null,"errorMessage":"GetChannelConn conn not found KChannel! {channelId}","messagePattern":"GetChannelConn conn not found KChannel! (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"Packages/cn.etetet.core/Scripts/Core/Share/Network/KService.cs","lineNumber":117,"sourceCode":"            }\n            \n            base.Dispose();\n            \n            foreach (long channelId in this.localConnChannels.Keys.ToArray())\n            {\n                this.Remove(channelId);\n            }\n\n            this.Transport.Dispose();\n            this.Transport = null;\n        }\n\n        public override (uint, uint) GetChannelConn(long channelId)\n        {\n            KChannel kChannel = this.Get(channelId);\n            if (kChannel == null)\n            {\n                throw new Exception($\"GetChannelConn conn not found KChannel! {channelId}\");\n            }\n            return (kChannel.LocalConn, kChannel.RemoteConn);\n        }\n        \n        public override void ChangeAddress(long channelId, IPEndPoint newIPEndPoint)\n        {\n            KChannel kChannel = this.Get(channelId);\n            if (kChannel == null)\n            {\n                return;\n            }\n            kChannel.RemoteAddress = newIPEndPoint;\n        }\n\n        private void Recv()\n        {\n            if (this.Transport == null)\n            {","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.core/Scripts/Core/Share/Network/KService.cs#L99-L135","documentation":"KService.GetChannelConn looks up a KChannel by id and throws when none is found. The channel was either never created, already removed (disposed/errored), or the id is stale.","triggerScenarios":"Querying a channel id after it was removed on disconnect/error, using an id from a previous service lifecycle, or a routing table pointing at a dead channel.","commonSituations":"Stale connection references held by a session manager, query racing with OnError cleanup, or wrong id passed.","solutions":["Get the channel and null-check before querying conn ids (use Get which returns null).","Clear id references when a channel is removed/disposed.","Tolerate a missing channel at the call site instead of throwing."],"exampleFix":"// before\n(uint l, uint r) = kService.GetChannelConn(channelId);\n// after\nvar ch = kService.Get(channelId);\nif (ch == null) return;\n(uint l, uint r) = (ch.LocalConn, ch.RemoteConn);","handlingStrategy":"validation","validationCode":"var ch = kService.Get(channelId);\nif (ch == null) { Log.Warning($\"channel {channelId} gone\"); return; }\n(uint l, uint r) = (ch.LocalConn, ch.RemoteConn);","typeGuard":"public bool HasChannel(long id) => Get(id) != null;","tryCatchPattern":"null","preventionTips":["Invalidate stored channel ids when channels are removed.","Null-check via Get before querying conn ids.","Make GetChannelConn return a default/bool-out variant instead of throwing."],"tags":["network","kcp","csharp"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}