eclipse-paho / paho.mqtt.java

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

java.lang.IllegalArgumentException: Invalid UTF-8 char: [a] #836

Open kavidriod opened 4 years ago

kavidriod commented 4 years ago

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

I'm trying to connect with mosquito broker via paho client (versions used are org.eclipse.paho.client.mqttv3-1.2.5.jar and org.eclipse.paho.client.mqttv3-1.2.1.jar)

When I try to connect I'm getting:

2020-09-29 20:43:24.233 12057-12057/com.paho.mqtt W/System.err: Connection lost (32109) - java.lang.IllegalArgumentException: Invalid UTF-8 char: [a]
2020-09-29 20:43:24.233 12057-12057/com.paho.mqtt W/System.err:     at org.eclipse.paho.client.mqttv3.internal.CommsSender.handleRunException(CommsSender.java:194)
2020-09-29 20:43:24.233 12057-12057/com.paho.mqtt W/System.err:     at org.eclipse.paho.client.mqttv3.internal.CommsSender.run(CommsSender.java:171)
2020-09-29 20:43:24.233 12057-12057/com.paho.mqtt W/System.err:     at java.lang.Thread.run(Thread.java:764)
2020-09-29 20:43:24.233 12057-12057/com.paho.mqtt W/System.err: Caused by: java.lang.IllegalArgumentException: Invalid UTF-8 char: [a]
2020-09-29 20:43:24.233 12057-12057/com.paho.mqtt W/System.err:     at org.eclipse.paho.client.mqttv3.internal.wire.MqttWireMessage.validateUTF8String(MqttWireMessage.java:407)
2020-09-29 20:43:24.233 12057-12057/com.paho.mqtt W/System.err:     at org.eclipse.paho.client.mqttv3.internal.wire.MqttWireMessage.encodeUTF8(MqttWireMessage.java:327)
2020-09-29 20:43:24.233 12057-12057/com.paho.mqtt W/System.err:     at org.eclipse.paho.client.mqttv3.internal.wire.MqttConnect.getPayload(MqttConnect.java:154)
2020-09-29 20:43:24.233 12057-12057/com.paho.mqtt W/System.err:     at org.eclipse.paho.client.mqttv3.internal.wire.MqttWireMessage.getHeader(MqttWireMessage.java:142)
2020-09-29 20:43:24.233 12057-12057/com.paho.mqtt W/System.err:     at org.eclipse.paho.client.mqttv3.internal.wire.MqttOutputStream.write(MqttOutputStream.java:74)
2020-09-29 20:43:24.233 12057-12057/com.paho.mqtt W/System.err:     at org.eclipse.paho.client.mqttv3.internal.CommsSender.run(CommsSender.java:147)
2020-09-29 20:43:24.234 12057-12057/com.paho.mqtt W/System.err:     ... 1 more

But I didn't get this issue in org.eclipse.paho.client.mqttv3-1.2.0.jar

Any help to resolve this?

Thanks in advance

mspoehr commented 4 years ago

I am getting this same error. Worked in version 1.1.0 (haven't tried 1.2.0).

kavidriod commented 4 years ago

Did you find solution for these?

I have tried in both org.eclipse.paho.client.mqttv3-1.2.5.jar and org.eclipse.paho.client.mqttv3-1.2.2.jar,Same issue is there from both of the jar files

mspoehr commented 4 years ago

Nope, just downgraded to 1.2.0.

kavidriod commented 4 years ago

Okay. I'm trying to upgrade paho client for fixing EOFException after referring to this link https://github.com/eclipse/paho.mqtt.java/issues/207#issuecomment-33824687

But Now I feel I don't have any option to resolve my EOF exception. Any comments here ?

kavidriod commented 4 years ago

I found reason for this exception. Actually I'm sending "X.509 open ssl certificate" as a password for Subscription. Which is having space character in the certificate. Since space is ISO character ,It is saying as "illegal Argument" from paho client 1.2.1 onwards.

From paho client 1.2.1 onwards,validateUTF8String() method is added in MqttWireMessage class.

In validateUTF8String() method if space is sent , Line number 400 -> Character.isISOControl(c) -> returns true So whole condition itself failed.

In Below image, Left is MqttWireMessage Source of paho client 1.2.0 and right side is paho client version of 1.2.1

image

Can anyone help me to solve this issue?

silh commented 4 years ago

Should de fixed in 818, there is a PR there but no reviews.

kavidriod commented 4 years ago

@silh ,Thanks for the Info. Any Idea whom to contact for the fix?

edhn3000 commented 3 years ago

I got the same error: java.lang.IllegalArgumentException: Invalid UTF-8 char: [d869] mqttv3 version 1.2.4 it make mqtt client disconnect and reconnect every times, will it be fix?

micw commented 2 years ago

@rdasgupt I have seen that you are currently one of the most active members in this project. May I point you attention to this issue? It is a blocker for many users who use encryption that was introduced with 1.2.1 and which is open since then. There's even an open PR for it.

Thank you a lot, Michael.

rdasgupt commented 2 years ago

@micw Could you point me to the open PR you have referred to in your last message?

micw commented 11 months ago

@rdasgupt I did not find it, maybe it was the PR for MQTTv5 I was looking at at this time. The Issue has been fixed for MQTTv5 (as stated in the initial report) but is still open for MQTTv3. Here is the commit that fixes it for MQTTv5: https://github.com/eclipse/paho.mqtt.java/commit/03186cb26514b964ffdd9fd6c8190f6b9e526932

The PR did not contain any tests, so I cannot tell if that really fixes this issue :-(

micw commented 11 months ago

I think the PR https://github.com/eclipse/paho.mqtt.java/pull/819/files solves the issue (and also adds tests). Problem is that the last release is >3 years old and does not contain the fix.