{"record":{"id":"c23c91602b1b058b","repo":"dotnet/aspnetcore","slug":"messages-over-2gb-in-size-are-not-supported","errorCode":null,"errorMessage":"Messages over 2GB in size are not supported","messagePattern":"Messages over 2GB in size are not supported","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/SignalR/clients/java/signalr/messagepack/src/main/java/com/microsoft/signalr/messagepack/Utils.java","lineNumber":45,"sourceCode":"        int length = 0;\n        int numBytes = 0;\n        int maxLength = 5;\n        byte curr;\n        \n        do {\n            // If we run out of bytes before we finish reading the length header, the message is malformed\n            if (buffer.hasRemaining()) {\n                curr = buffer.get();\n            } else {\n                throw new RuntimeException(\"The length header was incomplete\");\n            }\n            length = length | (curr & (byte) 0x7f) << (numBytes * 7);\n            numBytes++;\n        } while (numBytes < maxLength && (curr & (byte) 0x80) != 0);\n        \n        // Max header length is 5, and the maximum value of the 5th byte is 0x07\n        if ((curr & (byte) 0x80) != 0 || (numBytes == maxLength && curr > (byte) 0x07)) {\n            throw new RuntimeException(\"Messages over 2GB in size are not supported\");\n        }\n        \n        return length;\n    }\n    \n    public static ArrayList<Byte> getLengthHeader(int length) {\n        // This code writes length prefix of the message as a VarInt. Read the comment in\n        // the readLengthHeader for details.\n        \n        ArrayList<Byte> header = new ArrayList<Byte>();\n        do {\n            byte curr = (byte) (length & 0x7f);\n            length >>= 7;\n            if (length > 0) {\n                curr |= 0x80;\n            }\n            header.add(curr);\n        } while (length > 0);","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/SignalR/clients/java/signalr/messagepack/src/main/java/com/microsoft/signalr/messagepack/Utils.java#L27-L63","documentation":"The varint length prefix supports up to 5 bytes with a max 5th-byte value of 0x07, i.e. 0x7FFFFFFF (~2GB). A declared length exceeding that, or a varint that does not terminate within 5 bytes, is rejected outright as unsupported.","triggerScenarios":"A length prefix that decodes to a value greater than 2GB; a malformed/corrupt length prefix whose bits overflow the 5-byte varint limit.","commonSituations":"Corrupt framing producing a spuriously huge length; genuinely oversized payloads (not supported by design).","solutions":["Keep individual hub messages well under 2GB — chunk large data or use channel streaming.","Investigate framing corruption if the payload is known to be small."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Java - cap payload size before sending\nstatic final int MAX = Integer.MAX_VALUE;\nif (payloadBytes.length > MAX) {\n    throw new IllegalArgumentException(\"Payload exceeds the 2GB message limit\");\n}","typeGuard":null,"tryCatchPattern":"// Java\ntry {\n    hubConnection.send(\"Method\", payload).blockingAwait();\n} catch (RuntimeException ex) {\n    if (ex.getMessage() != null && ex.getMessage().contains(\"2GB\")) {\n    }\n}","preventionTips":["Keep individual hub messages well under 2GB.","Chunk large data or use channel-based streaming.","Investigate framing corruption if small payloads trip this."],"tags":["signalr","messagepack","size-limit","protocol"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}