hivemq / hivemq-mqtt-client

HiveMQ MQTT Client is an MQTT 5.0 and MQTT 3.1.1 compatible and feature-rich high-performance Java client library with different API flavours and backpressure support
https://hivemq.github.io/hivemq-mqtt-client/
Apache License 2.0
832 stars 153 forks source link

Infinite messages loop on Android release builds #537

Open symphonybiz opened 2 years ago

symphonybiz commented 2 years ago

Expected behavior

MQTT works normally on release builds by following the android guide: https://hivemq.github.io/hivemq-mqtt-client/docs/installation/android/

Actual behavior

On debug builds the client works fine, but on release builds we noticed the same MQTT message keeps being "received" forever in an infinite loop. This is seems to be happening because of proguard obfuscation.

Solution

We managed to fix this by adding an additional line to proguard:

-keep class com.hivemq.client.mqtt.mqtt5.message.Mqtt5Message { *; }
npace commented 2 years ago

The exception that gets thrown in this scenario is:

com.hivemq.client.mqtt.exceptions.ConnectionClosedException: java.lang.AbstractMethodError: abstract method "com.hivemq.client.mqtt.mqtt5.message.Mqtt5MessageType com.hivemq.client.internal.mqtt.message.MqttMessageWithUserProperties$WithReason$WithCode$WithId.getType()"

More specifically, it's not about debug vs release builds but rather about building with proguard vs without.

Devenom1 commented 1 year ago

I think I'm facing a similar issue, because on production build around 2-3 gb of data seems to be used per day. I'm using mqtt3 instead of mqtt5 though. How do I check if I'm receiving messages in a loop in production builds? Logs don't work.