question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exception raised when two MQTT client subscribes whith the same ClientID

See original GitHub issue

I 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:open
  • Created 6 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
dtflx01commented, Sep 19, 2017

Hi, Yes I think that the Broker should refuse new connection. Regards

0reactions
nkostiscommented, Jan 3, 2018

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found