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

Will payload can be set above 65.535 bytes #354

Closed
MicWalter opened this issue Dec 15, 2019 · 0 comments · Fixed by #355
Closed

Will payload can be set above 65.535 bytes #354

MicWalter opened this issue Dec 15, 2019 · 0 comments · Fixed by #355
Assignees
Labels
Milestone

Comments

@MicWalter
Copy link
Contributor

Expected behavior

As the spec states the Will publish payload is binary data (max 65.535 bytes), so the client should check if I set a payload higher than that.

Actual behavior

It is possible to exceed the binary data limit if I create a Mqtt5Publish and extend it as will. This breaks the encoding of the Connect packet.

To Reproduce

Reproducer code

 final @NotNull byte[] bytes = MqttCommonUtil.randomBytes(80_000);
        //throws error because payload exceeds binary data length 65_535
//        final Mqtt5WillPublish test = Mqtt5WillPublish.builder().topic("test").payload(bytes).build();

        //doesn't throw error because payload is not treated as binary data
        final Mqtt5Publish mqtt5Publish = Mqtt5Publish.builder().topic("test").payload(bytes).build();
        final Mqtt5WillPublish test2 = mqtt5Publish.extend().asWill().delayInterval(10).build();

        final Mqtt5AsyncClient retClient2 = Mqtt5Client.builder()
                .identifier("retsub")
                .simpleAuth().username("test").applySimpleAuth()
                .willPublish(test2).buildAsync();
        retClient2.connect().get();

Details

  • Affected HiveMQ MQTT Client version(s):
  • Used JVM version:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants