[ 
https://issues.apache.org/jira/browse/ARTEMIS-2506?focusedWorklogId=319493&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-319493
 ]

ASF GitHub Bot logged work on ARTEMIS-2506:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 27/Sep/19 11:31
            Start Date: 27/Sep/19 11:31
    Worklog Time Spent: 10m 
      Work Description: gaohoward commented on pull request #2853: ARTEMIS-2506 
MQTT doesn't cleanup underlying connection for bad clients
URL: https://github.com/apache/activemq-artemis/pull/2853#discussion_r329028964
 
 

 ##########
 File path: 
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/MQTTConnnectionCleanupTest.java
 ##########
 @@ -0,0 +1,84 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.tests.integration.mqtt;
+
+import org.apache.activemq.artemis.api.core.ActiveMQException;
+import org.apache.activemq.artemis.api.core.TransportConfiguration;
+import org.apache.activemq.artemis.core.protocol.mqtt.MQTTConnection;
+import org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptor;
+import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
+import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
+import 
org.apache.activemq.artemis.tests.integration.mqtt.imported.MQTTTestSupport;
+import org.fusesource.mqtt.client.BlockingConnection;
+import org.fusesource.mqtt.client.MQTT;
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class MQTTConnnectionCleanupTest extends MQTTTestSupport {
+
+   @Override
+   protected void addMQTTConnector() {
+
+      Map<String, Object> params = new HashMap<>();
+      params.put(TransportConstants.PORT_PROP_NAME, "" + port);
+      params.put(TransportConstants.PROTOCOLS_PROP_NAME, "MQTT");
+      params.put(TransportConstants.CONNECTIONS_ALLOWED, 1);
+      params.put(TransportConstants.HOST_PROP_NAME, "localhost");
+
+      TransportConfiguration mqtt = new 
TransportConfiguration(NETTY_ACCEPTOR_FACTORY, params, "MQTT");
+
+      server.getConfiguration().addAcceptorConfiguration(mqtt);
+   }
+
+   @Test(timeout = 30 * 1000)
+   public void testBadClient() throws Exception {
+      MQTT mqtt = createMQTTConnection();
+      mqtt.setClientId("");
+      mqtt.setCleanSession(true);
+      BlockingConnection connection = mqtt.blockingConnection();
+      connection.connect();
+
+      try {
+         connection = mqtt.blockingConnection();
+         connection.connect();
+         fail("second connection shouldn't be allowed");
+      } catch (Exception e) {
+         //ignore.
+      }
+
+      NettyAcceptor acceptor = (NettyAcceptor) 
server.getRemotingService().getAcceptor("MQTT");
+      assertEquals(1, acceptor.getConnections().size());
+
+      //now simulate a bad client by manually fail the server connection
+      RemotingConnection conn = 
server.getRemotingService().getConnections().iterator().next();
+
+      assertTrue(conn instanceof MQTTConnection);
+
+      conn.fail(new ActiveMQException("testBadClient"));
+
+      assertEquals("Server connection not cleaned up!", 0, 
acceptor.getConnections().size());
 
 Review comment:
   ok will do
   
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 319493)
    Time Spent: 0.5h  (was: 20m)

> MQTT doesn't cleanup underlying connection for bad clients
> ----------------------------------------------------------
>
>                 Key: ARTEMIS-2506
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-2506
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>          Components: MQTT
>    Affects Versions: 2.10.1
>            Reporter: Howard Gao
>            Assignee: Howard Gao
>            Priority: Major
>             Fix For: 2.11.0
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> When a bad MQTT clients drop its connection without proper closing it the 
> broker doesn't close the underlying physical connection. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to