Preview release on the 3.0 line. Brings in everything from 2.8.0-preview.1 via the main syncs, plus context-aware serialization. Three breaking changes in total, all intentional on the preview channel before stable 3.0. Please try it and report anything odd.
Package on NuGet: https://www.nuget.org/packages/NATS.Net
Breaking changes:
- Subject validation is on by default. Subjects containing whitespace (space, tab, CR, LF) now throw. Opt out with
SkipSubjectValidation = trueonNatsOpts. Closes a class of CRLF injection issues from malformed subjects. NATS.Client.Core.NKeysandNKeyPairare removed. Signing now goes through theNATS.NKeyspackage (https://www.nuget.org/packages/NATS.NKeys), which lets the nkey/Ed25519 code be versioned independently of the client.- Serializers that want access to message context during (de)serialization opt in via the new
INatsSerializeWithContext<T>/INatsDeserializeWithContext<T>interfaces (or the combinedINatsSerializerWithContext<T>). Existing serializers keep working unchanged; the library dispatches via runtime type check and falls back to the standard interface. Built-in serializers propagate the context through chains. The read-only flag onNatsHeadersis removed so context-aware serializers can mutate headers; a singleNatsHeadersinstance is no longer safe to share across concurrent publishes.
Also includes protocol size checks (64MB incoming payload cap, in line with nats.js), KV watcher cancellation fix, credential loading state reset on failure, and Pin ID handling improvements.
Thanks to the NATS community who contributed PRs, reviews, bug reports on this one ❤️
3.0-only since preview.2:
From main (also in 2.8.0-preview.1):
- auth: sign nonce regardless of auth_required (#1109) (thanks @Lionel-Zieminski)
- auth: use NATS.NKeys package for nkey signing (#1101) [breaking]
- conn: reset state on credential loading failure (#1107) (thanks @Prochy)
- Improve package metadata and README (#1103)
- tests: fix TlsPreferTest flap on net481 (#1108)
- Fix release workflow (#1106)
- Fix test flaps (#1083)
- ci: add contents and actions read permissions to Claude workflow (#1102)
- tls: document Prefer mode plaintext behavior (#1094)
- tests: increase NuidTests thread join timeouts (#1100)
- Improve Pin ID handling (#1099) (thanks @colprog)
- Fix KV watcher cancellation behavior (#1084)
- Clear ArrayPool buffers before returning to pool (#1097)
- Enable subject validation by default (#1093) [breaking]
- Add protocol size checks (#1095)
- Fix Range attribute for MaxBytes property (#1096) (thanks @partnerRuiSilva)
- Add CC reviews (#1092)
Full Changelog: v3.0.0-preview.2...v3.0.0-preview.3