MqttMessageBuilders builds invalid connect messages that `MqttEncoder.INSTANCE` seems to drop
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 35.1k
- Forks
- 16.3k
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 143
Description
Expected behavior
Trying to construct a connect message without a clientId should throw an exception,
as per http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718031
The Client Identifier (ClientId) MUST be present and MUST be the first field in the CONNECT packet payload[MQTT-3.1.3-3].
Actual behavior
instead the builder builds it, and the message never makes it through the pipeline, it seems to get dropped by MqttEncoder.INSTANCE without any kind of useful error message (even with TRACE level logging)
Steps to reproduce
Code to create the connect message
MqttMessageBuilders
.connect()
.username(Base64.getEncoder.encodeToString(deviceID.toBytes))
// Don't include this line
// .clientId("a-client-id")
.build()
pipeline code
ch.pipeline().addLast(new LoggingHandler(LogLevel.TRACE)) // For debugging
ch.pipeline().addLast("mqttDecoder", new MqttDecoder())
// This thing silently steals the connect message when we don't have client ID
ch.pipeline().addLast("mqttEncoder", MqttEncoder.INSTANCE)
ch.pipeline().addLast("DFEHandler", new OurHandlerThatProducesConnectMessages(config, logger))
Minimal yet complete reproducer code (or URL to code)
Netty version
4.1.73.Final
JVM version (e.g. java -version)
openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9 (build 11.0.11+9)
OpenJDK 64-Bit Server VM AdoptOpenJDK-11.0.11+9 (build 11.0.11+9, mixed mode)
OS version (e.g. uname -a)
21.6.0 Darwin Kernel Version 21.6.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing MqttMessageBuilders.connect() through MqttEncoder.INSTANCE using the provided pipeline and Netty 4.1.73.Final. Reproduce the missing-clientId case and inspect how the CONNECT payload is handled. Done means the invalid message produces a useful exception or error rather than being silently dropped, with coverage for the missing clientId behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100