{"action":"created","issue":{"url":"https://api.github.com/repos/andsel/moquette/issues/132","labels_url":"https://api.github.com/repos/andsel/moquette/issues/132/labels{/name}","comments_url":"https://api.github.com/repos/andsel/moquette/issues/132/comments","events_url":"https://api.github.com/repos/andsel/moquette/issues/132/events","html_url":"https://github.com/andsel/moquette/issues/132","id":121952893,"number":132,"title":"Broker restart hangs publishers","user":{"login":"yankyo","id":16281312,"avatar_url":"https://avatars.githubusercontent.com/u/16281312?v=3","gravatar_id":"","url":"https://api.github.com/users/yankyo","html_url":"https://github.com/yankyo","followers_url":"https://api.github.com/users/yankyo/followers","following_url":"https://api.github.com/users/yankyo/following{/other_user}","gists_url":"https://api.github.com/users/yankyo/gists{/gist_id}","starred_url":"https://api.github.com/users/yankyo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yankyo/subscriptions","organizations_url":"https://api.github.com/users/yankyo/orgs","repos_url":"https://api.github.com/users/yankyo/repos","events_url":"https://api.github.com/users/yankyo/events{/privacy}","received_events_url":"https://api.github.com/users/yankyo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-13T23:42:00Z","updated_at":"2016-01-28T13:11:25Z","closed_at":null,"body":"Restarting the moquette broker will cause all publishers (in the new broker session) to hang forever waiting for ACKs. Reproducible always with the most recent code as of the time of writing.\r\n\r\nSteps to reproduce:\r\n1. Start broker\r\n2. Start a subscriber\r\n3. While the client is still running, stop the broker\r\n4. Kill subscriber\r\n5. Start a new publisher and make it publish a message -- broker will fail with the message below and the publisher will never get the message acknowledged, no matter whether the original subscriber re-connects or not.\r\n\r\nBroker stack trace (OLD_SUB is the client from step 2, NEW_PUB from step 5):\r\n\r\n```\r\njava.lang.RuntimeException: Can't find a ConnectionDescriptor for client <OLD_SUB> in cache <{NEW_PUB=ConnectionDescriptor{clientID=NEW_PUB, cleanSession=true}}>\r\n        at io.moquette.spi.impl.ProtocolProcessor.directSend(ProtocolProcessor.java:509) ~[moquette-broker-0.8-SNAPSHOT.jar:na]\r\n        at io.moquette.spi.impl.ProtocolProcessor.route2Subscribers(ProtocolProcessor.java:473) ~[moquette-broker-0.8-SNAPSHOT.jar:na]\r\n        at io.moquette.spi.impl.ProtocolProcessor.processPubRel(ProtocolProcessor.java:558) ~[moquette-broker-0.8-SNAPSHOT.jar:na]\r\n        at io.moquette.server.netty.NettyMQTTHandler.channelRead(NettyMQTTHandler.java:70) ~[moquette-broker-0.8-SNAPSHOT.jar:na]\r\n        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308) [netty-transport-4.0.30.Final.jar:4.0.30.Final]\r\n        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294) [netty-transport-4.0.30.Final.jar:4.0.30.Final]\r\n        at io.moquette.server.netty.metrics.MessageMetricsHandler.channelRead(MessageMetricsHandler.java:46) [moquette-broker-0.8-SNAPSHOT.jar:na]\r\n        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308) [netty-transport-4.0.30.Final.jar:4.0.30.Final]\r\n        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294) [netty-transport-4.0.30.Final.jar:4.0.30.Final]\r\n        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:244) [netty-codec-4.0.30.Final.jar:4.0.30.Final]\r\n        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308) [netty-transport-4.0.30.Final.jar:4.0.30.Final]\r\n        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294) [netty-transport-4.0.30.Final.jar:4.0.30.Final]\r\n        at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86) [netty-transport-4.0.30.Final.jar:4.0.30.Final]\r\n        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308) [netty-transport-4.0.30.Final.jar:4.0.30.Final]\r\n        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294) [netty-transport-4.0.30.Final.jar:4.0.30.Final]\r\n        at io.moquette.server.netty.metrics.BytesMetricsHandler.channelRead(BytesMetricsHandler.java:47) [moquette-broker-0.8-SNAPSHOT.jar:na]\r\n        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308) [netty-transport-4.0.30.Final.jar:4.0.30.Final]\r\n        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294) [netty-transport-4.0.30.Final.jar:4.0.30.Final]\r\n        at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:266) [netty-handler-4.0.30.Final.jar:4.0.30.Final]\r\n        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308) [netty-transport-4.0.30.Final.jar:4.0.30.Final]\r\n        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294) [netty-transport-4.0.30.Final.jar:4.0.30.Final]\r\n        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846) [netty-transport-4.0.30.Final.jar:4.0.30.Final]\r\n        at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131) [netty-transport-4.0.30.Final.jar:4.0.30.Final]\r\n        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511) [netty-transport-4.0.30.Final.jar:4.0.30.Final]\r\n        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468) [netty-transport-4.0.30.Final.jar:4.0.30.Final]\r\n        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382) [netty-transport-4.0.30.Final.jar:4.0.30.Final]\r\n        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354) [netty-transport-4.0.30.Final.jar:4.0.30.Final]\r\n        at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:110) [netty-common-4.0.30.Final.jar:4.0.30.Final]\r\n        at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137) [netty-common-4.0.30.Final.jar:4.0.30.Final]\r\n        at java.lang.Thread.run(Thread.java:745) [na:1.8.0_66]\r\n```\r\n\r\nThe session information seems to be persisted -- the only way to restart broker without causing this issue is to make all subscribers disconnect first.\r\n\r\nExpected behaviour: broker, if restarted, cleans all the sessions (stopping the server will cause all clients to disconnect anyway)."},"comment":{"url":"https://api.github.com/repos/andsel/moquette/issues/comments/176176517","html_url":"https://github.com/andsel/moquette/issues/132#issuecomment-176176517","issue_url":"https://api.github.com/repos/andsel/moquette/issues/132","id":176176517,"user":{"login":"kailaico","id":12179898,"avatar_url":"https://avatars.githubusercontent.com/u/12179898?v=3","gravatar_id":"","url":"https://api.github.com/users/kailaico","html_url":"https://github.com/kailaico","followers_url":"https://api.github.com/users/kailaico/followers","following_url":"https://api.github.com/users/kailaico/following{/other_user}","gists_url":"https://api.github.com/users/kailaico/gists{/gist_id}","starred_url":"https://api.github.com/users/kailaico/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kailaico/subscriptions","organizations_url":"https://api.github.com/users/kailaico/orgs","repos_url":"https://api.github.com/users/kailaico/repos","events_url":"https://api.github.com/users/kailaico/events{/privacy}","received_events_url":"https://api.github.com/users/kailaico/received_events","type":"User","site_admin":false},"created_at":"2016-01-28T13:11:25Z","updated_at":"2016-01-28T13:11:25Z","body":"I also encountered this problem, the solution is: change the replacement of the proxy server version 0.8 (I am using is 0.8) to solve the above"}}