-
-
Notifications
You must be signed in to change notification settings - Fork 232
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
Subscriptions not effective on first connection #602
Comments
That's what |
Sure. But I would like it to receive messages even on first connection without having to disconnect and reconnect to make subscriptions effective. And I can obtain this behaviour if I use the embedded emitter. |
You can do this using |
Maybe I have not been clear enough. I'll try again. On its first connection my mqtt client: a) tries to subscribe to its topics, b) its subscripitions get recorded on mongo as everything went good, c) but the callback on Client#subscribe does not fire, d) and messages won't be delivered until my client disconnects and reconnects. Now, If I understood what you said, this is intendend to be the correct behaviour. Then to my understanding retaining messages is useless in my case because either:
|
ok now it is more clear, the problem essentially is:
This is strange, are you able to provide a piece of code that reproduce the problem? |
I'll be working on it, however so far I can tell you, as a side note, that the ghosting Client#subscribe callback fires at last, for example, on broker closed event. |
Ok, this code replicates the issue. package.json
Broker
Subscriber
Publisher
|
what's the content of |
Client#subscribe doesn't fail, it freezes. So this question has not an answer. |
I tried. Nothing changed. |
Same happens to me, only when closing subscription and and subscribing again i see the retained publish i make. So essentially when I am subscribed and I publish a message nothing shows up. Any tip? I have async methods inside authorizators should I make them synchronous? |
It's not safe to have them async, we don't handle any rejection in case it happens. BTW should be ok if you remember to call the callback |
Could be because we are not iterating the subscriptions array: https://github.com/moscajs/aedes/blob/main/lib/handlers/subscribe.js#L77 |
Hi everybody, I'm new to mqtt so I'm sorry if the question is silly.
Broker settings (over TLS):
Concurrency: 100
Emitter: redis emitter
Persistence: mongo
Client (mqtt.js)
Clean session: false
Attempts to subscribe a pair of topics on connect with QoS 2.
I encounter this problem:
if I connect the client to the broker, with clean session to false, subscription aren't (apparently) effective i.e.:
the callback on the subscriptions client event doesn't fire (nonetheless they show up in their own collection on mongo as expected)
if another client publishes on those subscriptions messages aren't delivered
But... if the guilty client disconnects and reconnects it gets every message it should have, as if subs had always been working.
If I use the aedes default emitter the problem does not exist, it does exist with redis and mongo emitters.
The problem ceases to exist even if the client connects with clean session true (but obviously I lose persistence and that's not what I want).
What is happening?
The text was updated successfully, but these errors were encountered: