{"record":{"id":"e370d2c5735011df","repo":"microsoft/garnet","slug":"unsupported-incoming-wire-format-protocol-input","errorCode":null,"errorMessage":"Unsupported incoming wire format {protocol} {input}","messagePattern":"Unsupported incoming wire format (.+?) (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"libs/server/Servers/GarnetServerTcp.cs","lineNumber":327,"sourceCode":"        /// <param name=\"bytes\"></param>\n        /// <param name=\"networkSender\"></param>\n        /// <param name=\"session\"></param>\n        /// <returns></returns>\n        public bool TryCreateMessageConsumer(Span<byte> bytes, INetworkSender networkSender, out IMessageConsumer session)\n        {\n            session = null;\n\n            // We need at least 4 bytes to determine session            \n            if (bytes.Length < 4)\n                return false;\n\n            WireFormat protocol = WireFormat.ASCII;\n\n            if (!GetSessionProviders().TryGetValue(protocol, out var provider))\n            {\n                var input = System.Text.Encoding.ASCII.GetString(bytes);\n                logger?.LogError(\"Cannot identify wire protocol {bytes}\", input);\n                throw new Exception($\"Unsupported incoming wire format {protocol} {input}\");\n            }\n\n            if (!AddSession(protocol, ref provider, networkSender, out session))\n                throw new Exception($\"Unable to add session\");\n\n            return true;\n        }\n\n        /// <inheritdoc />\n        public void DisposeMessageConsumer(INetworkHandler session)\n        {\n            if (activeHandlers.TryRemove(session, out _))\n            {\n                Interlocked.Decrement(ref activeHandlerCount);\n                IncrementConnectionsDisposed();\n                try\n                {\n                    session.Session?.Dispose();","sourceCodeStart":309,"sourceCodeEnd":345,"githubUrl":"https://github.com/microsoft/garnet/blob/951b0fc6838721f89d102c2bbe1b914e8d39d700/libs/server/Servers/GarnetServerTcp.cs#L309-L345","documentation":"Garnet's TryCreateMessageConsumer hardcodes the wire protocol to WireFormat.ASCII (RESP) and looks up the corresponding session provider. If the ASCII provider is not registered in the server's session provider dictionary, it throws. This is a server initialization error, not a client protocol error — the incoming bytes are decoded only for logging. In a standard Garnet server the RESP provider is always registered; this throw indicates a non-standard or incomplete server setup.","triggerScenarios":"Calling TryCreateMessageConsumer() when GetSessionProviders() does not contain WireFormat.ASCII. Occurs in custom/embedded server constructions that omit AddSession for RESP, or during teardown when providers have been removed but connections are still arriving.","commonSituations":"Building a custom GarnetServer without registering the standard RESP session provider; embedding Garnet in-process and misconfiguring the server pipeline; a race during server shutdown where providers are cleared before the listener fully stops.","solutions":["Ensure the GarnetServer instance is constructed with standard RESP session providers (GarnetServerOptions with standard providers, or manually call AddSession for WireFormat.ASCII).","If using an embedded/custom server, check that GetSessionProviders() contains WireFormat.ASCII before starting the TCP listener.","Verify you are not subclassing or wrapping GarnetServerTcp in a way that strips session provider registration."],"exampleFix":"// before (custom server missing provider)\nvar server = new GarnetServerTcp(options, logger);\nserver.Start();\n\n// after\nvar server = new GarnetServerTcp(options, logger);\nserver.AddSession(WireFormat.ASCII, new RespServerSessionProvider(...));\nserver.Start();","handlingStrategy":"validation","validationCode":"// Verify providers before starting the listener\nif (!server.GetSessionProviders().ContainsKey(WireFormat.ASCII))\n    throw new InvalidOperationException(\"RESP session provider not registered. Cannot accept connections.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["In custom/embedded setups, verify GetSessionProviders() contains WireFormat.ASCII before calling Start().","Use the standard GarnetServer constructors which register providers automatically.","During shutdown, stop the TCP listener before clearing session providers."],"tags":["network","wire-protocol","session","initialization","garnet"],"backgroundTag":null,"analyzedSha":"951b0fc6838721f89d102c2bbe1b914e8d39d700","analyzedAt":"2026-08-13T19:01:32.939Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}