Exception raised when two MQTT client subscribes whith the same ClientID
See original GitHub issueI found an Exception raised when two MQTT client subscribes whith the same ClientID. The exception is raised in MqttPublisherManager.cs in method PublishThread() in the following line
var query = from p in this.retainedMessages where (new Regex(subscription.Topic)).IsMatch(p.Key)
// check for topics based also on wildcard with regex
select p.Value;
Exception is raised because subscription.Topic is null.
Each ClientID must be unique, but if it happens, this issue appears.
Regards
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
How to handle multiple clients with same ID in mosquitto ...
The MQTT Spec says that client ids have to be unique and the correct behaviour is to kick the oldest one off and...
Read more >Handling Multiple MQTT Client Connections Using Python
A look at different methods for handling multiple MQTT client connections using loop_start and loop functions and threads.
Read more >Conflicting MQTT client IDs - AWS IoT Core
The MQTT specification allows only one active connection per client ID, so when another device connects using the same client ID, it knocks...
Read more >subscribeTimeoutException on shadowUpdate in ...
The device subscribes to a topic on the MQTTClient und performs sensor ... AWS IoT does not allow 2 connections with the same...
Read more >Multipe clients connecting with same clientID both keep ...
I'm using MQTT over websocket with mosca broker on server side. I connect clients by using a specific client id: websocket_ - and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hi, Yes I think that the Broker should refuse new connection. Regards
As Vladimir says and as is common behaviour among brokers, the broker should allow the connection of the new client and disconnect the existing one, since they’re considered the same client that tries to reconnect and the previous connection is “stale”. This may lead to attacks (if client id is known to others), but the other option would be to have stale connections remain stale forever (keep-alive can be disabled by a client).
so the question actually is: what does the broker currently do and how do you get into a situation where there are more than one clients with the same ID connected? Because i use this broker as well and what i’ve seen it do is to indeed disconnect the original one. And since my clients have an auto-reconnect mechanism, you actually see one client kick the other one out and vice versa for eternity