Open i-m-aj opened 4 years ago
I am also facing the same issue. And this issue occurs in android API 27 because the ResourceAuthenticator's checkValid uses DigestUtils.sha256Hex(...) and this is not available in API 27's commons codec. @amitkj-stack by any chance did you find any solution to this problem?
sha256Hex
which version you are using?
This piece of code is used inside moquette's ResourceAuthenticator. And internally this invokes Hex.encodeHexString which is not available in android api 27's runtime. Even if we use higher version of commons.codec in android project, during runtime it uses the Hex class present inside android's runtime which is a lower version. @amitkj-stack I hope you are also facing this issue in android rite?
What version of mqtt broker you are using?
0.15
For me, Its not coming for now. I am using old version 0.12.1 Cant you target min sdk 28. It will work from there only. I did it
what version of android are you using?
I'm also facing the same issue on Android using Android minSdk 24 and targetSdk 30, However when I replace it with new String(Base64.encodeBase64(bytes));, it encodes and generates a totally different String with an equal sign in the end here:
java.lang.NoSuchMethodError: No static method encodeHexString([B)Ljava/lang/String; in class Lorg/apache/commons/codec/binary/Hex; or its super classes (declaration of 'org.apache.commons.codec.binary.Hex' appears in /system/framework/org.apache.http.legacy.boot.jar)
I'm also facing the same issue on Android using Android minSdk 24 and targetSdk 30, However when I replace it with new String(Base64.encodeBase64(bytes));, it encodes and generates a totally different String with an equal sign in the end here:
java.lang.NoSuchMethodError: No static method encodeHexString([B)Ljava/lang/String; in class Lorg/apache/commons/codec/binary/Hex; or its super classes (declaration of 'org.apache.commons.codec.binary.Hex' appears in /system/framework/org.apache.http.legacy.boot.jar)
Here is the return Hex.encodeHexString(bytes) result: Access signature: ee3bddc9b353c337e81ddc08e3ed37eb5a01e11f961534ef03cedebe6f339e5c
And here is the new String(Base64.encodeBase64(bytes)); result: Access signature: aJAloUfELPGtEyaGGFkRXFl1QhBUZhet0R63pSDHU/Q=
They clearly do not perform the same encoding.
Moquette doesn't have direct support for Android, this means it's not tested, but if you provide a reproducer outside Android I'm more than happy to fix it.
I was using Java on Android. The underlying issue is not with Android. It's with the Java am using on Android.
[nioEventLoopGroup-5-1] ERROR io.moquette.broker.NewNettyMQTTHandler - Error processing protocol message: CONNECT
java.lang.NoSuchMethodError: No static method encodeHexString([B)Ljava/lang/String; in class Lorg/apache/commons/codec/binary/Hex; or its super classes (declaration of 'org.apache.commons.codec.binary.Hex' appears in /system/framework/org.apache.http.legacy.boot.jar)
at org.apache.commons.codec.digest.DigestUtils.sha256Hex(DigestUtils.java:500)
at io.moquette.broker.security.ResourceAuthenticator.checkValid(ResourceAuthenticator.java:124)
at io.moquette.broker.MQTTConnection.login(MQTTConnection.java:235)
The error arise at: https://github.com/moquette-io/moquette/blob/0b92f0fde9f89933ed50844414ca88bb6673a303/broker/src/main/java/io/moquette/broker/security/ResourceAuthenticator.java#L124
DigestUtils
is provided by the Apache library commons-codec:commons-codec
which Moquette defines as a dependency at: https://github.com/moquette-io/moquette/blob/0b92f0fde9f89933ed50844414ca88bb6673a303/broker/pom.xml#L131-L135
Maybe your Android project missed to include that, or excluded for some reason?
Hi, It doesn’t support newer versions of android. Its stable when you are running on lower versions of android.
Thanks and Regards : Amit Kumar Jaiswal https://www.linkedin.com/in/amit-kumar-jaiswal-b62a1a7b https://www.linkedin.com/in/amit-kumar-jaiswal-b62a1a7b (SDE- I Android)
On Fri, 9 Feb 2024 at 1:49 PM, Andrea Selva @.***> wrote:
Moquette doesn't have direct support for Android, this means it's not tested, but if you provide a reproducer outside Android I'm more than happy to fix it.
— Reply to this email directly, view it on GitHub https://github.com/moquette-io/moquette/issues/518#issuecomment-1935502957, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGNF7TCTRIEFRE6BNE7NLU3YSXLYFAVCNFSM4K4VF5Y2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJTGU2TAMRZGU3Q . You are receiving this because you were mentioned.Message ID: @.***>
Please could you share a repository with a minimal project that manifest it?
Please could you share a repository with a minimal project that manifest it?
I am using
So it's not up to date to support sdk levels greater than 28?
Please could you share a repository with a minimal project that manifest it?
I am using
- moquette ->v0.12.1
- androidTargetSdkVersion ->28
Moquette doesn't support officially Android, in general is ownership of who integrate Moquette into their apps to resolve such issues, but if you can isolate or describe well what the problem is, we could discuss on eventual fixes that would simply its integration in Android.
So it's not up to date to support sdk levels greater than 28?
Please could you share a repository with a minimal project that manifest it?
I am using
- moquette ->v0.12.1
- androidTargetSdkVersion ->28
Yes. https://github.com/moquette-io/moquette/issues/518#issuecomment-1943313421
It actually doesn’t not support well. @andsel mentioned that if you have specific issue that you can bring so we can look into it
Server Log 2020-02-28 13:03:11.970 20418-20876/ I/System.out: 117068 [nioEventLoopGroup-5-1] DEBUG io.moquette.broker.AutoFlushHandler - Initializing autoflush handler on channel [id: 0x82488a46, L:/172.16.1.196:1883 - R:/172.16.1.196:38308] Cid: null 2020-02-28 13:03:12.309 20418-20876/ I/System.out: 117404 [nioEventLoopGroup-5-1] INFO io.moquette.broker.metrics.MQTTMessageLogger - C->B CONNECT
2020-02-28 13:03:12.316 20418-20876/ I/System.out: 117412 [nioEventLoopGroup-5-1] DEBUG io.moquette.broker.MQTTConnection - Received MQTT message, type: CONNECT, channel: [id: 0x82488a46, L:/172.16.1.196:1883 - R:/172.16.1.196:38308]
2020-02-28 13:03:12.431 20418-20876/ I/System.out: 117431 [nioEventLoopGroup-5-1] ERROR io.moquette.broker.NewNettyMQTTHandler - Error processing protocol message: CONNECT
2020-02-28 13:03:12.431 20418-20876/ I/System.out: java.lang.NoSuchMethodError: No static method encodeHexString([B)Ljava/lang/String; in class Lorg/apache/commons/codec/binary/Hex; or its super classes (declaration of 'org.apache.commons.codec.binary.Hex' appears in /system/framework/org.apache.http.legacy.boot.jar)
2020-02-28 13:03:12.432 20418-20876/ I/System.out: at org.apache.commons.codec.digest.DigestUtils.sha256Hex(DigestUtils.java:500)
2020-02-28 13:03:12.432 20418-20876/ I/System.out: at io.moquette.broker.security.ResourceAuthenticator.checkValid(ResourceAuthenticator.java:124)
2020-02-28 13:03:12.432 20418-20876/ I/System.out: at io.moquette.broker.MQTTConnection.login(MQTTConnection.java:235)
2020-02-28 13:03:12.432 20418-20876/ I/System.out: at io.moquette.broker.MQTTConnection.processConnect(MQTTConnection.java:160)
2020-02-28 13:03:12.432 20418-20876/ I/System.out: at io.moquette.broker.MQTTConnection.handleMessage(MQTTConnection.java:67)
2020-02-28 13:03:12.433 20418-20876/ I/System.out: at io.moquette.broker.NewNettyMQTTHandler.channelRead(NewNettyMQTTHandler.java:58)
2020-02-28 13:03:12.433 20418-20876/ I/System.out: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
2020-02-28 13:03:12.433 20418-20876/ I/System.out: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
2020-02-28 13:03:12.433 20418-20876/ I/System.out: at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
2020-02-28 13:03:12.433 20418-20876/ I/System.out: at io.moquette.broker.metrics.MQTTMessageLogger.channelRead(MQTTMessageLogger.java:46)
2020-02-28 13:03:12.434 20418-20876/ I/System.out: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
2020-02-28 13:03:12.434 20418-20876/ I/System.out: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
2020-02-28 13:03:12.434 20418-20876/ I/System.out: at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
2020-02-28 13:03:12.434 20418-20876/ I/System.out: at io.moquette.broker.metrics.MessageMetricsHandler.channelRead(MessageMetricsHandler.java:50)
2020-02-28 13:03:12.434 20418-20876/ I/System.out: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
2020-02-28 13:03:12.435 20418-20876/ I/System.out: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
2020-02-28 13:03:12.435 20418-20876/ I/System.out: at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
2020-02-28 13:03:12.435 20418-20876/ I/System.out: at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:310)
2020-02-28 13:03:12.436 20418-20876/ I/System.out: at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:284)
2020-02-28 13:03:12.436 20418-20876/ I/System.out: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
2020-02-28 13:03:12.436 20418-20876/ I/System.out: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
2020-02-28 13:03:12.436 20418-20876/ I/System.out: at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
2020-02-28 13:03:12.437 20418-20876/ I/System.out: at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86)
2020-02-28 13:03:12.437 20418-20876/ I/System.out: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
2020-02-28 13:03:12.437 20418-20876/ I/System.out: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
2020-02-28 13:03:12.437 20418-20876/ I/System.out: at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
2020-02-28 13:03:12.437 20418-20876/ I/System.out: at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86)
2020-02-28 13:03:12.438 20418-20876/ I/System.out: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
2020-02-28 13:03:12.438 20418-20876/ I/System.out: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
2020-02-28 13:03:12.438 20418-20876/ I/System.out: at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
2020-02-28 13:03:12.438 20418-20876/ I/System.out: at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286)
2020-02-28 13:03:12.439 20418-20876/ I/System.out: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
2020-02-28 13:03:12.439 20418-20876/ I/System.out: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
2020-02-28 13:03:12.439 20418-20876/ I/System.out: at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
2020-02-28 13:03:12.439 20418-20876/ I/System.out: at io.moquette.broker.metrics.BytesMetricsHandler.channelRead(BytesMetricsHandler.java:51)
2020-02-28 13:03:12.439 20418-20876/ I/System.out: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
2020-02-28 13:03:12.439 20418-20876/ I/System.out: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
2020-02-28 13:03:12.440 20418-20876/ I/System.out: at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
2020-02-28 13:03:12.440 20418-20876/ I/System.out: at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1414)
2020-02-28 13:03:12.440 20418-20876/ I/System.out: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
2020-02-28 13:03:12.440 20418-20876/ I/System.out: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
2020-02-28 13:03:12.440 20418-20876/ I/System.out: at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:945)
2020-02-28 13:03:12.441 20418-20876/ I/System.out: at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:146)
2020-02-28 13:03:12.441 20418-20876/ I/System.out: at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:645)
2020-02-28 13:03:12.441 20418-20876/ I/System.out: at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:580)
2020-02-28 13:03:12.441 20418-20876/ I/System.out: at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:497)
2020-02-28 13:03:12.442 20418-20876/ I/System.out: at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459)
2020-02-28 13:03:12.442 20418-20876/ I/System.out: at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:886)
2020-02-28 13:03:12.442 20418-20876/ I/System.out: at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
2020-02-28 13:03:12.442 20418-20876/ I/System.out: at java.lang.Thread.run(Thread.java:764)
2020-02-28 13:03:12.450 20418-20876/ I/System.out: 117548 [nioEventLoopGroup-5-1] INFO io.moquette.broker.NewNettyMQTTHandler - Closed client channel due to exception in processing
// Paho Client Log 2020-02-28 13:03:12.469 20418-20418/ W/System.err: Connection lost (32109) - java.io.EOFException 2020-02-28 13:03:12.469 20418-20418/ W/System.err: at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:190) 2020-02-28 13:03:12.470 20418-20418/ W/System.err: at java.lang.Thread.run(Thread.java:764) 2020-02-28 13:03:12.471 20418-20418/ W/System.err: Caused by: java.io.EOFException 2020-02-28 13:03:12.471 20418-20418/ W/System.err: at java.io.DataInputStream.readByte(DataInputStream.java:270) 2020-02-28 13:03:12.472 20418-20418/ W/System.err: at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:92) 2020-02-28 13:03:12.472 20418-20418/ W/System.err: at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:137) 2020-02-28 13:03:12.472 20418-20418/ W/System.err: ... 1 more