Skip to content

How to handle max_payload limit? #31

@jkrcma

Description

@jkrcma

I've been trying to code my app so it can react to various max_payload sizes provided by NATS server properly, including a rewrite from text-based content to a simple binary one with fixed byte-lengths. But then I found out that STAN implements certain message structures on top of NATS protocol using protobuf and that protobuf isn't fixed in the byte-length. So basically I can't determine the exact message length I can send through the client because I don't know how large the protobuf overhead is.

One of the ideas which got in my mind was to patch the publish method so it will create the protobuf structure first, filling the clientID, guid and subject. Then if payload is a callback calling it and passing the structure into it so my code can dynamically generate a part of payload inside with the exact byte-length.

The other idea is maybe cleaner and consists of separating the protobuf structure instantiation into a separate factory method, allowing publish to accept the object directly.

What do you think about it? Or do you have any other ideas? I don't want to avoid the problem by setting the max_payload server-side to any unreal number or doing any wibbly wobbly bisection aka do ... while raises exception.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions