Added a script to check 2 clients with same ID fails
This commit is contained in:
+4
-4
@@ -144,8 +144,8 @@
|
|||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.paho</groupId>
|
<groupId>org.eclipse.paho</groupId>
|
||||||
<artifactId>mqtt-client</artifactId>
|
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||||
<version>0.4.0</version>
|
<version>1.0.1</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@@ -214,11 +214,11 @@
|
|||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<!--repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>Paho Releases</id>
|
<id>Paho Releases</id>
|
||||||
<url>https://repo.eclipse.org/content/repositories/paho-releases/</url>
|
<url>https://repo.eclipse.org/content/repositories/paho-releases/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
|
||||||
</repositories-->
|
</repositories>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -172,6 +172,7 @@ class ProtocolProcessor implements EventHandler<ValueEvent> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_clientIDs.get(msg.getClientID()).getSession().close(false);
|
m_clientIDs.get(msg.getClientID()).getSession().close(false);
|
||||||
|
LOG.info("Found an existing connection with same client ID <{}>, forced to close", msg.getClientID());
|
||||||
}
|
}
|
||||||
|
|
||||||
ConnectionDescriptor connDescr = new ConnectionDescriptor(msg.getClientID(), session, msg.isCleanSession());
|
ConnectionDescriptor connDescr = new ConnectionDescriptor(msg.getClientID(), session, msg.isCleanSession());
|
||||||
|
|||||||
+4
-4
@@ -150,8 +150,8 @@
|
|||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.paho</groupId>
|
<groupId>org.eclipse.paho</groupId>
|
||||||
<artifactId>mqtt-client</artifactId>
|
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||||
<version>0.4.0</version>
|
<version>1.0.1</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
@@ -221,10 +221,10 @@
|
|||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<!--repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>Paho Releases</id>
|
<id>Paho Releases</id>
|
||||||
<url>https://repo.eclipse.org/content/repositories/paho-releases/</url>
|
<url>https://repo.eclipse.org/content/repositories/paho-releases/</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories-->
|
</repositories>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
@GrabResolver(name='Paho', root='https://repo.eclipse.org/content/repositories/paho-releases/')
|
||||||
|
@Grab(group='org.eclipse.paho', module='org.eclipse.paho.client.mqttv3', version='1.0.1', ext='jar')
|
||||||
|
|
||||||
|
|
||||||
|
import org.eclipse.paho.client.mqttv3.MqttClient
|
||||||
|
import org.eclipse.paho.client.mqttv3.MqttMessage
|
||||||
|
import org.eclipse.paho.client.mqttv3.MqttException
|
||||||
|
import org.eclipse.paho.client.mqttv3.persist.MqttDefaultFilePersistence
|
||||||
|
|
||||||
|
String host = args[0]
|
||||||
|
|
||||||
|
String tmpDir = System.getProperty("java.io.tmpdir")
|
||||||
|
MqttDefaultFilePersistence dataStore1 = new MqttDefaultFilePersistence(tmpDir + "/client1")
|
||||||
|
MqttClient client1 = new MqttClient("tcp://${host}:1883", "ConnectedClient", dataStore1)
|
||||||
|
client1.connect()
|
||||||
|
println "Client1 connected"
|
||||||
|
client1.subscribe("topic", 0)
|
||||||
|
println "Client1 subscribed to topic"
|
||||||
|
|
||||||
|
sleep(500)
|
||||||
|
|
||||||
|
//now connect a second client but with the same ID
|
||||||
|
MqttDefaultFilePersistence dataStore2 = new MqttDefaultFilePersistence(tmpDir + "/client2")
|
||||||
|
MqttClient client2 = new MqttClient("tcp://${host}:1883", "ConnectedClient", dataStore2)
|
||||||
|
client2.connect()
|
||||||
|
println "Client2 connected"
|
||||||
|
client2.subscribe("topic", 0)
|
||||||
|
println "Client2 subscribed to topic"
|
||||||
|
|
||||||
|
client1.disconnect()
|
||||||
|
println "Client1 disconnected"
|
||||||
|
|
||||||
|
client2.disconnect()
|
||||||
|
println "Client2 disconnected"
|
||||||
Reference in New Issue
Block a user