Light, fluffy, and always free - The AWS Local Emulator alternative
fix(apigatewayv2): raise Vert.x WebSocket frame size limit to 256 KB (#938)
Dixit R Jainc0d6b71eb1b9
diff --git a/src/main/java/io/github/hectorvent/floci/config/HttpOptionsCustomizer.java b/src/main/java/io/github/hectorvent/floci/config/HttpOptionsCustomizer.javaindex c9d9e0c8f3..ee9c614ede 100644--- a/src/main/java/io/github/hectorvent/floci/config/HttpOptionsCustomizer.java+++ b/src/main/java/io/github/hectorvent/floci/config/HttpOptionsCustomizer.java@@ -5,30 +5,53 @@ import io.vertx.core.http.HttpServerOptions;import jakarta.enterprise.context.ApplicationScoped;/**- * Removes the 8 KB per-attribute limit imposed by Vert.x's default- * {@code HttpServerOptions.maxFormAttributeSize}.+ * Customizes Vert.x HTTP server options for Floci's requirements.*- * Without this, any request that arrives with- * {@code Content-Type: application/x-www-form-urlencoded} and a single- * attribute value larger than ~8 KB is rejected by Netty's form decoder- * with "Size exceed allowed maximum capacity". This hits real AWS APIs- * that use the Query Protocol: CloudFormation templates, EC2 UserData- * (base64-encoded), large IAM policies, etc.+ * <ul>+ * <li>Removes the 8 KB per-attribute limit imposed by Vert.x's default+ * {@code HttpServerOptions.maxFormAttributeSize}. Without this, any request+ * with {@code Content-Type: application/x-www-form-urlencoded} and a single+ * attribute value larger than ~8 KB is rejected by Netty's form decoder.+ * This hits real AWS APIs that use the Query Protocol: CloudFormation templates,+ * EC2 UserData (base64-encoded), large IAM policies, etc.</li>+ * <li>Raises the WebSocket frame and message size limits to accommodate payloads+ * up to 128 KB, matching the AWS API Gateway WebSocket payload limit. Vert.x+ * defaults to 64 KB per frame, which causes Netty to silently reject larger+ * frames before the application-level size check in+ * {@code WebSocketHandler} can fire.</li>+ * </ul>** The overall request body size is still bounded by- * {@code quarkus.http.limits.max-body-size} (default 512 MB), so raising- * the per-attribute limit to unlimited is safe.+ * {@code quarkus.http.limits.max-body-size} (default 512 MB).*/@ApplicationScopedpublic class HttpOptionsCustomizer implements HttpServerOptionsCustomizer {+ /**+ * Maximum WebSocket frame size: 256 KB.+ * AWS API Gateway allows up to 128 KB payloads. We set the transport limit higher+ * so that oversized frames (e.g. 128 KB + 1 byte) still reach the application-level+ * handler in {@code WebSocketHandler}, which sends back a proper error response.+ */+ private static final int MAX_WS_FRAME_SIZE = 256 * 1024;++ /**+ * Maximum WebSocket message size (reassembled from multiple frames).+ * Set to the same value as the frame limit.+ */+ private static final int MAX_WS_MESSAGE_SIZE = 256 * 1024;+@Overridepublic void customizeHttpServer(HttpServerOptions options) {options.setMaxFormAttributeSize(-1);+ options.setMaxWebSocketFrameSize(MAX_WS_FRAME_SIZE);+ options.setMaxWebSocketMessageSize(MAX_WS_MESSAGE_SIZE);}@Overridepublic void customizeHttpsServer(HttpServerOptions options) {options.setMaxFormAttributeSize(-1);+ options.setMaxWebSocketFrameSize(MAX_WS_FRAME_SIZE);+ options.setMaxWebSocketMessageSize(MAX_WS_MESSAGE_SIZE);}}