Skip to content

MQTT subscribe Remaining Length encoding is incorrect #969

Description

@peterhinch

See this discussion for background, also MQTT spec V3.1.1 section 2.2.3.

This may be academic as its main impact is if the topic field is long. This is to record the existence of the issue.

The current encoding stores Remaining Length in a byte. It should be stored as a Variable Byte Integer as per .publish. This will cause a failure if Remaining Length is greater than 127, therefore imposing a limit on the length of the topic field.

I can submit a PR if the maintainers think this is worth fixing.

Activity

  1. pablogventura commented on Jul 16, 2026

    @pablogventura
    Contributor

    Opened #1142 with a minimal fix: encode Remaining Length for subscribe and unsubscribe as a Variable Byte Integer, matching the existing publish pattern, plus mock on-wire tests for short and long topics.

  2. added a commit that references this issue on Jul 28, 2026
    8c30067
  3. added a commit that references this issue on Aug 22, 2026
    e13a8e8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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