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

Unsubscribe get stuck #370

Closed
dborovcanin opened this issue Oct 24, 2019 · 2 comments
Closed

Unsubscribe get stuck #370

dborovcanin opened this issue Oct 24, 2019 · 2 comments

Comments

@dborovcanin
Copy link
Contributor

Unsubscribe token.Wait() waits indefinitely, even if Unsubscribe Ack is received. This was not happening before PR 361. Looks like the problem is related to the code removed from net.go. You can use the following snippet to get stuck:

	mc := mqtt.NewClient(opts)
	token := mc.Connect()
	token.Wait()
	if err := token.Error(); err != nil {
		fmt.Printf(err)
		return
	}
	mc.Subscribe(topic, 2, handler)
	// Wait for SUB ACK.
	time.Sleep(3 * time.Second)
	if mc.Unsubscribe(topic).Wait() {
		fmt.Println("done")
	}
        // Never reached. Network inspection shows Unsubscribe ACK received.
	fmt.Println("never reached")
@dborovcanin dborovcanin changed the title Unsubscribe gets stuck Unsubscribe get stuck Oct 24, 2019
@alsm alsm closed this as completed in 79454df Oct 24, 2019
@alsm
Copy link
Contributor

alsm commented Oct 24, 2019

Thanks for reporting this, I didn't notice that the changes that were made for subscribe hadn't been made for unsubscribe and it didn't break the tests (unfortunately)

@robbawebba
Copy link
Contributor

@dusanb94 I apologize for breaking the behavior of your application (and probably others), and thank you @alsm for fixing the issue! I totally forgot about the unsubscribe flow because my application does not use the unsubscribe features of this client, and I just relied on the library's test suite for verifying that I did not break any existing functionality.

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

3 participants