Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numerous connect/disconnect when mosca server does not grant access to topic at publish time #97

Open
rudivk opened this issue Dec 29, 2017 · 0 comments

Comments

@rudivk
Copy link

rudivk commented Dec 29, 2017

mqtt.zip
We plan to add authentication to our MQTT server using a simple strategy, inspired by what is being discussed on https://auth0.com/docs/integrations/authenticating-devices-using-mqtt. All of our topics contain the user's identification (e.g. /poc/mqtt/user-id/example) so it suffices for us to accept all connections and then deny access to publish on a topic when the user id is not part of the topic. In other words, a user that connected with id "rudi" will not be allowed to publish to "poc/mqtt/joost/example".
I have attached our mqtt configuration and authorization (see mqtt.zip).

What we have noticed is that when the producer connects with e.g. user id "rudi" and then attempts to publish on topic "poc/mqtt/joost/example" the fusesource library produces numerous connect/disconnect resulting in a high CPU load on the mqtt process. Since our mqtt server will be public on the intenert, that high cpu load looks like an easy denial of service attack so I want to avoid that. I have also noticed that when we add a Thread.sleep(2000) into the onDisconnect method of the ConnectionListener, the problem goes away entirely, meaning it is likely a timing issue inside the fusesource library.

I have also attached our "producer" code that reproduces the problem.
producer.zip

To reproduce the problem:

  1. unzip the mqtt.zip in a folder of your choice and execute: node start-mosca.js
  2. unzip producer.zip in a folder of your choice
  3. mvn clean package (optional because maven target directory is part of the zip)
  4. run the producer script (./producer.sh)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant