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

Repeated end events did not properly disconnect #1666

Closed
Canees opened this issue Aug 8, 2023 · 3 comments
Closed

Repeated end events did not properly disconnect #1666

Canees opened this issue Aug 8, 2023 · 3 comments

Comments

@Canees
Copy link

Canees commented Aug 8, 2023

Problem description:
It disconnects correctly the first time.
When I connect a second time, do end again and it doesn't disconnect.

Use version:
latest version

expect:
It can disconnect correctly

fragment:
`
const sleep = (ms) => new Promise(res => setTimeout(res, ms));
const a = mqtt.connect('mqtt://127.0.0.1:49800', { username: 'test', password: 'test',manualConnect:true})
a.connect()
await sleep(5000)
a.end() //It disconnects correctly

await sleep(3000)
a.connect() //It connects correctly

await sleep(1000)
a.end() // It does not disconnect correctly
`

@robertsLando
Copy link
Member

robertsLando commented Aug 8, 2023

After calling end you should recreate a new instance, end it's like destroy, it removes some listeners and other stuff that make the instance not usable anymore

@Canees
Copy link
Author

Canees commented Aug 8, 2023

After calling end you should recreate a new instance, end it's like destroy, it removes some listeners and other stuff that make the instance not usable anymore

Yes, I have modified it. It always feels strange. Perhaps it is not semantic enough? Like new connect()?

@robertsLando
Copy link
Member

Yeah but I keep all this stuff for v6. See #1648

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

2 participants