Git Product home page Git Product logo

Comments (10)

chriswiggins avatar chriswiggins commented on July 30, 2024

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.

mcollina avatar mcollina commented on July 30, 2024

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.

chriswiggins avatar chriswiggins commented on July 30, 2024

"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.

mcollina avatar mcollina commented on July 30, 2024

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.

mcollina avatar mcollina commented on July 30, 2024

Any news on this side? Could you please try the new released version?

from mosca.

mcollina avatar mcollina commented on July 30, 2024

It include the SSL support!

from mosca.

chriswiggins avatar chriswiggins commented on July 30, 2024

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.

mcollina avatar mcollina commented on July 30, 2024

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.

mcollina avatar mcollina commented on July 30, 2024

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.

chriswiggins avatar chriswiggins commented on July 30, 2024

Merged :-)

from mosca.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.