tokio-serde icon indicating copy to clipboard operation
tokio-serde copied to clipboard

Fails on large software

Open Yuri6037 opened this issue 2 years ago • 1 comments

I have a large client-server software where the messages are encoded and decoded through bincode and may contain a bunch of strings, integers, floats, etc.

I recently tried to move to tokio which simplifies and fixes portability bugs (random os error 35 on macOS for example). To move the code I've used tokio-serde to support deserializing the packets serialize through bincode. Unfortunately, every-time a packet contains a bunch of strings tokio-serde errors with "frame size too big".

Is there any workaround to this bug?

Yuri6037 avatar Apr 26 '22 18:04 Yuri6037

If you using LengthDelimitedCodec then default value of max_frame_length is 8MB so everything above 8MB in size will get rejected with that message.

Use LengthDelimitedCodec::builder() and set your desired max_frame_length on it, like so:

  let len_codec = LengthDelimitedCodec::builder()
      .max_frame_length(8 * 1024 * 1024) // 8MB
      .new_codec();

WeaponMan avatar Aug 14 '22 14:08 WeaponMan