MuntashirAkon/AppManager · error · IOException
Message is too large:
Error message
Message is too large:
What it means
DataTransmission frames each message with a 4-byte length header, capped at MAX_MESSAGE_SIZE. sendMessage(byte[]) throws IOException when the payload exceeds that cap, before anything is written, to prevent protocol/frame corruption. The exception message includes the offending length.
Solutions
- Split the payload into chunks below MAX_MESSAGE_SIZE and reassemble at the receiver
- Compress the payload before sending
- Write large data to a file and send a path/reference instead of the bytes
Example fix
// before
transmission.sendMessage(hugeBytes);
// after
for (int i = 0; i < hugeBytes.length; i += MAX_MESSAGE_SIZE) {
int n = Math.min(MAX_MESSAGE_SIZE, hugeBytes.length - i);
byte[] chunk = Arrays.copyOfRange(hugeBytes, i, i + n);
if (chunk.length == MAX_MESSAGE_SIZE) chunk[chunk.length-1] &= 0x7f; // obey encoder cap if needed
transmission.sendMessage(chunk);
} Defensive patterns
Strategy: validation
Validate before calling
if (messageBytes == null || messageBytes.length <= MAX_MESSAGE_SIZE) {
transmission.sendMessage(messageBytes);
} else {
// chunk or compress
} Try / catch
try {
transmission.sendMessage(bytes);
} catch (IOException e) {
if (e.getMessage() != null && e.getMessage().startsWith("Message is too large")) {
// chunk the payload and retry
} else throw e;
} Prevention
- Check payload size against MAX_MESSAGE_SIZE before sending
- Chunk or compress large payloads
- Send file paths instead of large blobs
When it happens
Trigger: Calling sendMessage(byte[]) with an array larger than MAX_MESSAGE_SIZE (e.g. sending a whole file blob or oversized serialized object through the privileged-service channel).
Common situations: Streaming large command output or bulk data without chunking; a server reply that grows beyond the fixed frame limit; protocol misuse treating the channel as a raw stream.
Understand the failure class
Background: payload too large / request exceeds maximum size: why libraries cap bytes and how to fix oversize payloads — this error's family across 50 libraries.
Related errors
- Invalid message length:
- Can't unparcel type " + actual.getName() + " in list of…
- Client protocol version:
- ERROR_MSG (constant; invalid/unknown file handle for…
- Invalid userId
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/47e2d5686887f9db.
Report an issue: GitHub.
Appendix: source
Thrown at libserver/src/main/java/io/github/muntashirakon/AppManager/server/common/DataTransmission.java:119
*/
public void sendMessage(@Nullable String text) throws IOException {
if (text != null) {
sendMessage(text.getBytes());
}
}
/**
* Send message as bytes
*
* @param messageBytes Bytes to be sent
* @throws IOException When it fails to send the message
* @see #sendMessage(String)
* @see #sendAndReceiveMessage(byte[])
*/
public void sendMessage(@Nullable byte[] messageBytes) throws IOException {
if (messageBytes != null) {
if (messageBytes.length > MAX_MESSAGE_SIZE) {
throw new IOException("Message is too large: " + messageBytes.length);
}
mOutputStream.writeInt(messageBytes.length);
mOutputStream.write(messageBytes);
mOutputStream.flush();
}
}
/**
* Read response as bytes after sending a message
*
* @return The bytes to be read
* @throws IOException When it fails to read the message
*/
@NonNull
private byte[] readMessage() throws IOException {
int len = mInputStream.readInt();
if (len < 0 || len > MAX_MESSAGE_SIZE) {
throw new IOException("Invalid message length: " + len);View on GitHub (pinned to 0152f468fc)