hivemq-community-edition
hivemq-community-edition copied to clipboard
Client not shutting down all threads
I'm trying to do a graceful shutdown of com.hivemq.client.mqtt.mqtt3.Mqtt3AsyncClient, but have some threads that seem to not bing shut down. I attempt to shut down by calling disconnect() on my single Mqtt3AsyncClient.
Expected behavior
All threads spawned by Mqtt3AsyncClient what aren't daemon threads to be shut down automatically after disconnecting the client.
Actual behavior
I'm seeing this non-daemon thread remaining indefinitely:
"com.hivemq.client.mqtt-2-1@17300" prio=10 tid=0x42 nid=NA runnable java.lang.Thread.State: RUNNABLE at sun.nio.ch.KQueue.poll(KQueue.java:-1) at sun.nio.ch.KQueueSelectorImpl.doSelect(KQueueSelectorImpl.java:122) at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:124) - locked <0x4bd6> (a sun.nio.ch.KQueueSelectorImpl) - locked <0x4bd7> (a io.netty.channel.nio.SelectedSelectionKeySet) at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:136) at io.netty.channel.nio.SelectedSelectionKeySetSelector.select(SelectedSelectionKeySetSelector.java:62) at io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:883) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:526) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.lang.Thread.run(Thread.java:829)
To Reproduce
Run the Mqtt3AsyncClient with a clean session configured like this:
Mqtt3ClientBuilder clientBuilder = MqttClient.builder()
.identifier(mMyIdentifier)
.serverHost(settings.getAddress())
.serverPort(settings.getPort())
.addConnectedListener(this)
.addDisconnectedListener(this)
.automaticReconnectWithDefaultConfig()
.useMqttVersion3();
- Affected HiveMQ CE version(s): hivemq-mqtt-client 1.3.3
- Used JVM version: Java 11
Is there some other method to make it shut down properly?
Mike