github nats-io/nats.net v3.4.0
NATS .NET v3.4.0

one hour ago

NuGet

This release changes how the client decides to use TLS and which servers it takes from the cluster. Read Breaking below before upgrading.

Breaking:

  • A tls:// or wss:// URL is always connected to with TLS. With TlsMode.Prefer, a tls:// URL used to be opportunistic, so a server that did not offer TLS got a plaintext connection. It now fails (#1300)
  • A tls:// or wss:// URL among the configured servers requires TLS for every server, configured or discovered, in the default TlsMode.Auto. A list that mixes nats:// with tls:// or wss:// no longer connects to a server without TLS. Set TlsMode.Prefer to keep each URL as written (#1300)
  • With TLS after INFO, servers are discovered only from INFO received inside TLS. The connect_urls in the plaintext INFO sent before the TLS upgrade are no longer used. nats-server 2.12 and later sends an INFO inside TLS after the first PONG, so discovery works as before. Against nats-server before 2.12, other cluster members are not discovered until a later INFO brings them, which happens when cluster membership changes. List all servers in the URL to keep failover. Plaintext, handshake-first TLS and WebSocket connections are unchanged (#1300)
  • Discovered servers are dialled with the transport and TLS of the connection they were learned on. A connect_urls entry can no longer pick the scheme, so a server cannot move the client to plaintext or to another transport. A server learned over TLS keeps TLS when it is reported again over a plaintext connection (#1300)
  • connect_urls entries must be host or host:port. Entries with a scheme, user info, a path, whitespace or control characters are skipped with a warning. An entry with user info (x@host:port) used to make the client log in to that server as x; configure such a server directly with its credentials instead (#1300)
  • When TLS is required, a socket from SocketConnectionFactory or OnSocketAvailableAsync must support it. It must implement INatsTlsUpgradeableSocketConnection, so the client can upgrade it, or the new INatsTlsSocketConnection, to declare that it already provides TLS. Any other socket connection fails the attempt instead of carrying credentials in plaintext. TLS is required by a tls:// or wss:// URL, certificate or CA options, or TlsMode.Require or TlsMode.Implicit (#1300)
  • A ws:// URL is refused when TLS is required, and a wss:// URL with TlsMode.Disable fails on connect. These configuration errors fail ConnectAsync even with RetryOnInitialConnect. Use wss:// for TLS over WebSocket (#1300)
  • The server must send INFO first. Anything received before it fails the connection attempt, and the client retries as per its reconnect options (#1300)

New:

  • INatsTlsSocketConnection for custom socket connections that set up TLS themselves (#1300)
  • NatsJSOrderedConsumerOpts.NamePrefix names the consumers an ordered consumer creates {NamePrefix}_1, {NamePrefix}_2 and so on, instead of random names, as other clients allow (#1293)

Fixed:

  • A failed handshake-first TLS handshake closes the socket and fails the attempt. Previously the client could go on with the socket in plaintext (#1300)
  • INFO still buffered from a closed connection no longer changes the server info or the discovered servers after a reconnect (#1300)
  • An INFO without connect_urls no longer clears the discovered servers, and a malformed entry no longer stops the reconnect loop (#1300)
  • Errors for a required TLS name what made it required (the URL scheme, a tls:// or wss:// URL in the list, certificate options, or the mode) instead of always "TlsMode is set to Require" (#1300)
  • NatsSvcServer.StopAsync drains endpoints instead of disposing them, so requests already on the wire when the service stops are handled instead of dropped, as RemoveEndpointAsync already did for a single endpoint (#1282)

Thanks to @Ivandemidov00 for the service drain fix, and to @jnmoyne for asking for the ordered consumer name prefix.

Don't miss a new nats.net release

NewReleases is sending notifications on new releases.