eclipse-paho / eclipse-paho/paho.mqtt.java

Invalid Packet Type

Open
#1,030 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2.3k
Forks
918
PR merge metrics
No merged PRs in 30d

Description

After some time of usage, the Pharo-client just disconnects with the error:

relates to REASON_CODE_INVALID_MESSAGE

```
Paket nicht erkannt (32108)
at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:31)
at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:99)
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:137)
```

Restarting the application immediately produces the same error again, only restarting the broker helps (for some time)

So, apparently the broker is sending "something" invalid there.

However, this exception can't be handled code-wise (from the app) because paho itself decides that this is a non-recoverable error and goes into stop-state. at:

```
catch (MqttException ex) {
//@TRACE 856=Stopping, MQttException
log.fine(CLASS_NAME,methodName,"856",null,ex);
synchronized (lifecycle) {
target_state = State.STOPPED;
}
// Token maybe null but that is handled in shutdown
clientComms.shutdownConnection(token, ex);
}
```

Any Workarounds to "reject / ignore" invalid messages?
Other MQTT-Clients are just working fine at the same time.

Contributor guide

Open the contributing guide

Research direction

Start with MqttInputStream.readMqttWireMessage and the ExceptionHelper.createMqttException stack trace, then follow CommsReceiver.run into clientComms.shutdownConnection. Reproduce the invalid-packet disconnect if possible and determine whether the client can reject or ignore the message without entering STOPPED state; done means the behavior is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.