Comments (10)
Also to note is that when a client times out, the binding isn't removed from the backend side (amqp in our case) whereas if the client disconnects itself it is removed. Is this by design?
from mosca.
Your problem is happening because your clients are being authorized, then they subscribe successfully and in the end the connection is closed.
I think there are two problems: firstly you should not call the close
method inside the authenticate
function, but you should call the callback with a false argument, like it's done in the built-in authenticate
: https://github.com/mcollina/mosca/blob/master/lib/authorizer.js#L80-L82.
However, that behavior is definitely a bug and it even may be exploited in some way. The main reason is that in this lines the unsubAndClose
method is not called: https://github.com/mcollina/mosca/blob/master/lib/client.js#L251-L258.
Actually, your second issue is the very same bug. Here the unsubAndClose
method is not called: https://github.com/mcollina/mosca/blob/master/lib/client.js#L251-L258.
I think the unsubAndClose
method should disappear and moved it inside close
.
Could you please work a pull-request out of this? Please, also add a couple of unit tests.
from mosca.
"Your problem is happening because your clients are being authorized, then they subscribe successfully and in the end the connection is closed."
I think you misunderstood the scenario :-) I am disconnecting the OLD client (by looping through the list of currently connected clients and finding the one that has the same username) but I think the idea of where the issue lies is the same. I'll work on the fix tomorrow
from mosca.
Oh yes, definitely. However the problem is the very same.
Looping through all clients seems highly inefficient: you should definitely maintain a map of usernames and their client representation.
from mosca.
Any news on this side? Could you please try the new released version?
from mosca.
It include the SSL support!
from mosca.
Hi @mcollina, sorry it has been a busy week! Will look at getting onto this ASAP. Should I be moving all of the work that is done in unsubAndClose just into close? Will create a pull request when done
from mosca.
I've fixed a couple of problems on that.. give it a go in master and see. You can also have a look at #56.
I think the whole "close" situation is a total mess: there are three (!!) methods for closing called in different moments and the thing is not really tested.
As a start, you can remove the unsubAndClose method, but I'd like to have unit test for covering this functionality.
from mosca.
I think we should fix this soon, as we are not complaint with MQTT in this regard. The spec says:
If a client with the same Client ID is already connected to the server, the "older" client must be disconnected by the server before completing the CONNECT flow of the new client
from mosca.
Merged :-)
from mosca.
Related Issues (20)
- Mosca, Docker, Reverse Proxy and Real IP
- Error: invalid schema, expected mongodb
- How we can Subscribe/Unsubscribe topics for particular client from mosca broker
- Why two processes...
- Feature request: remove retained messages
- client.on get stuck waiting for message HOT 2
- TIME_WAIT issue
- How to bridge to zmq?
- infinite loop via npm install
- Mqtt broker is disconnecting frequently even though it has a unique client id
- Strange ip address
- MQTT over WS with Mosca+Express HOT 3
- Redis TLS option not supported
- password in authenticate function is a buffer
- regex used on looking up retained messages HOT 1
- How to configure TLS correctly in Mosca HOT 2
- fullergalway/kafkamqtt not found
- Feature Request: Use Node 10 worker threads for real parallelization
- How to get a list of connected clients?
- [question]I cannot get more than 200 connections HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mosca.