eclipse / paho.mqtt.java

Eclipse Paho Java MQTT client library. Paho is an Eclipse IoT project.
https://eclipse.org/paho
Other
2.12k stars 883 forks source link

validateQos() Crash #394

Open ishaansrm opened 7 years ago

ishaansrm commented 7 years ago

Please fill out the form below before submitting, thank you!

This is the stacktrace:

Fatal Exception: java.lang.IllegalArgumentException
       at org.eclipse.paho.client.mqttv3.MqttMessage.validateQos(MqttMessage.java:41)
       at org.eclipse.paho.client.mqttv3.MqttMessage.setQos(MqttMessage.java:181)
       at org.eclipse.paho.client.mqttv3.internal.wire.MqttPublish.(MqttPublish.java)
       at org.eclipse.paho.client.mqttv3.internal.wire.MqttWireMessage.createWireMessage(MqttWireMessage.java:193)
       at org.eclipse.paho.client.mqttv3.internal.wire.MqttWireMessage.createWireMessage(MqttWireMessage.java:167)
       at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:119)
       at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:116)
       at java.lang.Thread.run(Thread.java:841)

I understand that validateQos() is receiving an invalid QOS, but is the client trying to publish that invalid QOS message or is it received on the client in a malformed way from the broker?

As per my understanding of this stack trace, the client received a msg which it failed to convert into a valid MqttMessage due to an invalid QOS. Is that right? It's a confusing stacktrace :(

IanWambai commented 7 years ago

Facing the same issue.

jpwsutton commented 7 years ago

@ishaansrm & @IanWambai What type of MQTT Server are you using?

ishaansrm commented 7 years ago

Mosquitto broker

IanWambai commented 7 years ago

Same.

IanWambai commented 6 years ago

@jpwsutton were you able to figure out what's causing the issue?

jpwsutton commented 6 years ago

@IanWambai Sadly not as I cannot re-create this issue myself. Could you enable logging following the instructions here and show us the log messages that appear with this exception please?

ishaansrm commented 6 years ago

Will enable logging too. Please note that I've been able to see the issue only in production, never on my test bed.

ishaangarg commented 6 years ago

Is it possible to enable logging in production java (android) apps? If yes then how? As per my understanding we need to push the props file to java client but that's be difficult to do for production clients.

This crash is only seen in production.

jpwsutton commented 6 years ago

You would need to modify the launch command to include the -Djava.util.logging.config.file=/path/to/logging/file, that's the only requirement.

chris-lg commented 5 years ago

Hi, have u fixed this bug?

DavyHubrecht commented 4 years ago

I have the same issue. I received this exception log without a clear cause. As this can't be caught outside of the library's code, I propose catching this internally.

strautins commented 4 years ago

For me this issue was because of wrong server address/port as serverURI in new MqttClient(...). As you can see at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:116) ~ feels like message incoming decode fails.

MauliShah31 commented 3 years ago

I am facing this issue randomly in my Android application. As this exception can not be caught outside of the library, this need to be caught in the library itself.

Fix of this crash is needed.

zhuxiaoxue commented 2 years ago

For me this issue was because of wrong server address/port as serverURI in new MqttClient(...). As you can see at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:116) ~ feels like message incoming decode fails.

Right, but how do I know if the address/port is correct?

j5shi commented 3 weeks ago

Facing the same issue, received an invalid QoS, got no idea what happened.