Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Length-delimited framing actually emitting big-endian length, not little-endian #19699

Open
blind-oracle opened this issue Jan 24, 2024 · 0 comments
Labels
domain: codecs Anything related to Vector's codecs (encoding/decoding) type: bug A code related bug.

Comments

@blind-oracle
Copy link

A note for the community

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Problem

The docs for framing in sinks say:

length_delimited

Event data is prefixed with its length in bytes.
The prefix is a 32-bit unsigned integer, little endian.

Where in fact this framing emits Big Endian-encoded integer.
Documentation needs to be fixed.

See here, the tokio_util::codec::LengthDelimitedCodec codec is used:

pub struct LengthDelimitedEncoder(LengthDelimitedCodec);

And this codec emits big-endian: https://docs.rs/tokio-util/latest/tokio_util/codec/length_delimited/#getting-started

The returned transport implements Sink + Stream for BytesMut. It encodes the frame with a big-endian u32 header denoting the frame payload length:

I've confirmed it when I was writing a server to receive Vector events.

Configuration

socket:
    type: socket
    inputs:
    - parse_logs
    
    mode: unix
    path: /tmp/foo.socket

    encoding:
      codec: text
    
    framing:
      method: length_delimited
    
    healthcheck:
      enabled: false

Version

0.35

Debug Output

No response

Example Data

No response

Additional Context

No response

References

No response

@blind-oracle blind-oracle added the type: bug A code related bug. label Jan 24, 2024
@jszwedko jszwedko added the domain: codecs Anything related to Vector's codecs (encoding/decoding) label Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain: codecs Anything related to Vector's codecs (encoding/decoding) type: bug A code related bug.
Projects
None yet
Development

No branches or pull requests

2 participants