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

Connection resumed after long downtime, but no messages received #475

Closed
raRaRa opened this issue Mar 2, 2024 · 4 comments
Closed

Connection resumed after long downtime, but no messages received #475

raRaRa opened this issue Mar 2, 2024 · 4 comments
Labels
feature-request A feature should be added or improved. p3 This is a minor priority issue

Comments

@raRaRa
Copy link

raRaRa commented Mar 2, 2024

Describe the bug

My issue is 100% like #117 which is now closed.

  1. Network is down for over several hours, and then it goes back up and resumes the MQTT connection.
  2. Everything looks normal but the client never recieves any messages. Kinda as if the subscription got lost?

Based on the information on the old issue that I referenced, it says I need to manually re-subscribe if session_present is false when the connection is resumed in connection_success My initial thought was that this library would handle the re-connection by itself.

I tried debugging the internal state and saw that the connection_count increases with time, when network is down and goes up after several hours. Is it because a new session was created?

I would love to have more information on this.

Thanks!

Expected Behavior

I expected the connection to resume without any silent failure.

Current Behavior

The connection is resumed but no messages are received

Reproduction Steps

  1. Connect to MQTT and subscribe to a topic
  2. Turn off the network on the PC for 2-4 hours
  3. Turn on the network on the PC
  4. Whe connection is resumed, note how the client recieves no messages. Also note that session_present is false in connection_success

Possible Solution

Re-subscribe to the topics automatically if re-connection is handled by this SDK.

Additional Information/Context

Using browser version

SDK version used

1.19.1

Environment details (OS name and version, etc.)

Browser Chrome on MacOS

@raRaRa raRaRa added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Mar 2, 2024
@bretambrose bretambrose added feature-request A feature should be added or improved. and removed bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Mar 2, 2024
@raRaRa
Copy link
Author

raRaRa commented Mar 3, 2024

@bretambrose Do you know if this is by design or if this is a bug? I encountered the same issue today but it behaved differently.

After MQTT resumed the connection, it took around 5 minutes until I started receiving messages. I even tried unsubscribing and subscribing to the same topic without any luck. It does feel like an internal bug since unsubbing and subbing again to the topic had no effect.

Is there a way to turn on internal debug logging? (on browser)

@bretambrose
Copy link
Contributor

The SDK does not perform resubscription for you. Resubscription sounds easy but quickly devolves into edge cases. Ultimately, it feels like a correct application will still need to handle the edge case where resubscription fails anyways.

The browser variant is a wrapper around mqtt-js, so debug logging turns into interacting with its logging facilities (which in my experience are very unsatisfactory). I have the following in my notes from years ago, no guarantees, I have memories that every time I've tried to do this it's been an annoying/unfruitful process:

    let debug = require('debug');
    debug.enable('mqttjs*');
    debug.log = console.info.bind(console);

@jmklix jmklix added the p3 This is a minor priority issue label Mar 4, 2024
@jmklix
Copy link
Member

jmklix commented May 17, 2024

There will always be edge cases for reconnecting that will need to be handled correctly. This feature isn't something we are currently planning on implementing because of resource constraints.

@jmklix jmklix closed this as completed May 17, 2024
Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved. p3 This is a minor priority issue
Projects
None yet
Development

No branches or pull requests

3 participants