Commit 7466819
fix(resubscribe): message id allocate twice (mqttjs#1337)
* fix: messageeId
* Fix messageId allocate twice on deliver.
resubscribe is out of MQTT spec. It is MQTT.js expansion.
On connect sequence, the following three steps are defined by the MQTT Spec.
1. The client sends CONNECT to the broker with CleanStart:false
2. The broker sends CONNACK to the client with SessionPresent:true if
session exists
3. The client re-sends in-flight PUBLISH and PUBREL messages
resubscribe was processed between the step 2 and step 3.
It's too early. The resubscribe might allocate messageId that is the
same as PUBLISH or PUBREL packet. It is not good.
So I moved resubscribe process to after the step 3.
* Removed invalid fallback code.
* Stored CONNACK packet instead of sessionPresent.
Co-authored-by: Yoseph Maguire <yoseph.maguire@gmail.com>1 parent e3e15c3 commit 7466819
1 file changed
Lines changed: 6 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
335 | 335 | | |
336 | 336 | | |
337 | 337 | | |
| 338 | + | |
338 | 339 | | |
339 | 340 | | |
340 | 341 | | |
| |||
343 | 344 | | |
344 | 345 | | |
345 | 346 | | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
| 347 | + | |
350 | 348 | | |
351 | 349 | | |
352 | 350 | | |
| |||
360 | 358 | | |
361 | 359 | | |
362 | 360 | | |
363 | | - | |
| 361 | + | |
364 | 362 | | |
365 | 363 | | |
366 | 364 | | |
| |||
1674 | 1672 | | |
1675 | 1673 | | |
1676 | 1674 | | |
1677 | | - | |
| 1675 | + | |
1678 | 1676 | | |
1679 | 1677 | | |
1680 | 1678 | | |
1681 | | - | |
| 1679 | + | |
1682 | 1680 | | |
1683 | 1681 | | |
1684 | 1682 | | |
| |||
1714 | 1712 | | |
1715 | 1713 | | |
1716 | 1714 | | |
| 1715 | + | |
1717 | 1716 | | |
1718 | 1717 | | |
1719 | | - | |
1720 | 1718 | | |
1721 | 1719 | | |
1722 | 1720 | | |
| |||
0 commit comments