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

mqtt: WIP: Read variable header indepentenly from payload #13465

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

schicho
Copy link
Contributor

@schicho schicho commented Apr 24, 2024

Started by me in a discussion at #13448


current upstream implementation

The MQTT publish packet sent by a broker to a subscribing client is only parsed for the fixed header indicating the packet type.

However, the packet itself still contains a variable header indicating the topic length, topic and packet ID. http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718039 (Section 3.3.2)

The whole variable header and the following payload is output by the curl tool. Yet, we know that the first two bytes are the topic length, which, given that it is significantly short, results in the first byte being x00. That results in curl aborting the output and warning of binary output. This makes curl unsuitable for testing any MQTT functionality on the command line.

proposed change

Break the current implementation and provide the variable header values topic and header ID as header values hidden behind a -v flag like with HTTP.

The output will now only be the actual payload of the packet.

You may want to test this with the -N flag. Otherwise you won't see the output immediately.

further discussion points

  • Unfortunately, I have little C experience, the code works-ish
  • Curl_client_write(data, CLIENTWRITE_HEADER,... does not what I expect it to do, also no way to set the header name, is it even the correct approach?
  • What's the best approach to correlate the headers with the payload in this streaming setting?
  • Further @bagder mentioned in the discussion that this poses the question how binary payloads should be handled.

@github-actions github-actions bot added the MQTT label Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

None yet

1 participant