-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Observed behavior
We are using NATS to get data off of IoT devices that can only communicate over MQTT. Since upgrading to NATS version 2.12.2 from our old version (2.11.9), we have noticed a regression where, when clients disconnect and reconnect (ex: client system restarted), they get a wrong last sequence: 0 error. This is presumably because the NATS broker is expecting the next number in the sequence, but it is receiving 0 (since, from the client side, it's its first message to the broker).
We believe this may be related to the issue observed in this PR: #7478
Example, full error log with client IDs removed
[3429948] 2025/12/01 18:59:59.206458 [ERR] 10.161.19.240:55298 - mid:991694 - "CLIENT_ID_REDACTED" - unable to persist session "CLIENT_ID_REDACTED" (seq=2883553): wrong last sequence: 0 (10071)
Our temporary workaround is to have clients reconnect with random characters appended to the end of their client ID.
Expected behavior
The expected behavior would be what we saw in our previous version (2.11.9), which is that clients could restart with sequence 0 without running into this error.
Server and client version
Our new version is 2.12.2, previously we were on 2.11.9
Clients are using MQTT, they do not use NATS directly
Host environment
No response
Steps to reproduce
We have attempted to reproduce this issue in development environments and cannot do so reliably (though, it does happen sometimes).
This leads us to believe that the issue may be related to some kind of error in the disconnect (i.e. if the client disconnects gracefully, this may not happen, but if a client is disconnected forcefully, this may be more likely to happen). Note this is only a theory