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

Continuously giving the error pipeline did not handle the exception #564

Closed gelbertgel closed 11 months ago

gelbertgel commented 1 year ago

šŸ› Bug Report

I want to establish connection in SSL protocol. I add TrustManagerFactory, serverHost etc. I keep getting this error when I try to connect to mqtt in the background:

An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception. io.netty.channel.ChannelPipelineException: com.hivemq.client.internal.mqtt.handler.MqttChannelInitializer.handlerAdded() has thrown an exception; removed. at io.netty.channel.DefaultChannelPipeline.callHandlerAdded0(DefaultChannelPipeline.java:624) at io.netty.channel.DefaultChannelPipeline.access$100(DefaultChannelPipeline.java:46) at io.netty.channel.DefaultChannelPipeline$PendingHandlerAddedTask.execute(DefaultChannelPipeline.java:1463) at io.netty.channel.DefaultChannelPipeline.callHandlerAddedForAllHandlers(DefaultChannelPipeline.java:1115) at io.netty.channel.DefaultChannelPipeline.invokeHandlerAddedIfNeeded(DefaultChannelPipeline.java:650) at io.netty.channel.AbstractChannel$AbstractUnsafe.register0(AbstractChannel.java:502) at io.netty.channel.AbstractChannel$AbstractUnsafe.register(AbstractChannel.java:468) at io.netty.channel.SingleThreadEventLoop.register(SingleThreadEventLoop.java:87) at io.netty.channel.SingleThreadEventLoop.register(SingleThreadEventLoop.java:81) at io.netty.bootstrap.AbstractBootstrap.initAndRegister(AbstractBootstrap.java:323) at io.netty.bootstrap.Bootstrap.doResolveAndConnect(Bootstrap.java:155) at io.netty.bootstrap.Bootstrap.connect(Bootstrap.java:148) at com.hivemq.client.internal.mqtt.handler.connect.MqttConnAckSingle.connect(MqttConnAckSingle.java:91)

šŸ”¬ How To Reproduce

Steps to reproduce the behavior:

  1. Enter your mqtt information into the app.
  2. Connect to mqtt in foreground
  3. Kill the app.
  4. Send a message to Subscribe.
  5. Get this error in background

Code sample

    client = MqttClient.builder()
            .useMqttVersion5()
            .automaticReconnectWithDefaultConfig()
            .identifier(getClientId())
            .serverHost(getUrl())
            .serverPort(getSelectPort())
            .addConnectedListener(this)
            .addDisconnectedListener(this)
            .sslConfig()
            .trustManagerFactory(trustManagerFactory)
            .applySslConfig()
            .buildAsync();

Environment

Device info: General Mobile Android One Android 12

Which MQTT protocol version is being used? SSL