dotnet/aspnetcore · error · RuntimeException
Messages over 2GB in size are not supported
Error message
Messages over 2GB in size are not supported
What it means
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.
Source
Thrown at src/SignalR/clients/java/signalr/messagepack/src/main/java/com/microsoft/signalr/messagepack/Utils.java:45
int length = 0;
int numBytes = 0;
int maxLength = 5;
byte curr;
do {
// If we run out of bytes before we finish reading the length header, the message is malformed
if (buffer.hasRemaining()) {
curr = buffer.get();
} else {
throw new RuntimeException("The length header was incomplete");
}
length = length | (curr & (byte) 0x7f) << (numBytes * 7);
numBytes++;
} while (numBytes < maxLength && (curr & (byte) 0x80) != 0);
// Max header length is 5, and the maximum value of the 5th byte is 0x07
if ((curr & (byte) 0x80) != 0 || (numBytes == maxLength && curr > (byte) 0x07)) {
throw new RuntimeException("Messages over 2GB in size are not supported");
}
return length;
}
public static ArrayList<Byte> getLengthHeader(int length) {
// This code writes length prefix of the message as a VarInt. Read the comment in
// the readLengthHeader for details.
ArrayList<Byte> header = new ArrayList<Byte>();
do {
byte curr = (byte) (length & 0x7f);
length >>= 7;
if (length > 0) {
curr |= 0x80;
}
header.add(curr);
} while (length > 0);View on GitHub (pinned to 294cab2f9b)
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.
Defensive patterns
Strategy: validation
Validate before calling
// Java - cap payload size before sending
static final int MAX = Integer.MAX_VALUE;
if (payloadBytes.length > MAX) {
throw new IllegalArgumentException("Payload exceeds the 2GB message limit");
} Try / catch
// Java
try {
hubConnection.send("Method", payload).blockingAwait();
} catch (RuntimeException ex) {
if (ex.getMessage() != null && ex.getMessage().contains("2GB")) {
}
} Prevention
- Keep individual hub messages well under 2GB.
- Chunk large data or use channel-based streaming.
- Investigate framing corruption if small payloads trip this.
When it happens
Trigger: A length prefix that decodes to a value greater than 2GB; a malformed/corrupt length prefix whose bits overflow the 5-byte varint limit.
Common situations: Corrupt framing producing a spuriously huge length; genuinely oversized payloads (not supported by design).
Related errors
- Cannot read message size.
- Messages bigger than 2GB are not supported.
- MessagePack message was length %d but claimed to be length %
- Error reading length header.
- Error reading MessagePack data.
AI-assisted analysis of dotnet/aspnetcore@294cab2f9b (2026-08-06).
Data as JSON: /api/errors/c23c91602b1b058b.
Report an issue: GitHub.