actix-extras icon indicating copy to clipboard operation
actix-extras copied to clipboard

Support setting maximum WebSocket frame size for streaming (non-actor) handlers

Open singularsyntax opened this issue 1 year ago • 2 comments

Expected Behavior

There should be a way to increase the maximum WebSocket frame size for streaming (non-actor) stream handlers. Whenever sending large payloads through WebSockets, I'm getting this error on the server:

WebSocket stream error: payload reached size limit

Current Behavior

As per above.

Possible Solution

I attempted to implement solution on an in-tree branch of actix-extras, but it is not working:

https://github.com/singularsyntax/actix-extras/commit/18c17b5027d64060a0bf659eaa48f15df7efe89a

Steps to Reproduce (for bugs)

  1. Generate a WebSocket message frame on a client exceeding the default max frame size (64k).

Context

Your Environment

  • rustc 1.78.0 (9b00956e5 2024-04-29)
  • actix-* crate versions: actix-ws = "0.2.5"

singularsyntax avatar Jul 30 '24 19:07 singularsyntax

I guess what we want is something similar to actix-web-actor's WsResponseBuilder in actix-ws.

robjtede avatar Aug 07 '24 02:08 robjtede

+1 on this; this is blocking our migration from the now deprecated actix-web-actors

dinmukhamedm avatar Aug 12 '24 20:08 dinmukhamedm

I think https://github.com/actix/actix-extras/pull/430 addresses this well enough, and as outlined in the example, one can:

let (response, mut session, stream) = actix_ws::handle(&req, body)?;

// increase the maximum allowed frame size to 128KiB and aggregate continuation frames
let mut stream = stream.max_frame_size(128 * 1024).aggregate_continuations();

Does that mean we still need a builder? I was playing around trying to add a builder, and saw no additional value. It feels like this post-initialization configuration on the stream makes more sense.

@robjtede what are your thoughts?

dinmukhamedm avatar Oct 07 '24 21:10 dinmukhamedm

agreed, this is satisfied by #430

robjtede avatar Oct 07 '24 22:10 robjtede