We're happy to announce a new NATS .NET release v2.5.16. This release fixes various bugs and introduces a couple of nice features: Socket Connection Factory (enables going through proxies, potentially for other interesting stuff too!) and Direct Request Reply (an internal library improvement). We also want to announce that we have stopped testing against .NET 6.0 although we are still targeting it.
What's Changed
- Stopped testing with net6.0 by @mtmk in #821
- Fix netstandard bugs and tidy up tests by @mtmk in #817
- Docs examples update by @mtmk in #822
- Use Stopwatch in PingCommand for more precise timing by @mtmk in #827
- Make NatsJSConstants public by @aradalvand in #825
- Fix proxy with TLS scenario with SocketConnectionFactory by @wolfkor in #826
- Socket Connection Factory by @caleblloyd in #828
- Add direct request-reply by @mtmk in #829
- Update JetStream models by @mtmk in #832
Socket Connection Factory
Thanks to @wolfkor and @caleblloyd creating this abstraction, we now have a way of plugging in any implementation that could read and write buffers not just network sockets. Current use case is to enable going through forward proxies but we can't wait to see what other use cases are possible, perhaps can help with testing for example. (#826, #828)
public interface INatsSocketConnection : IAsyncDisposable
{
ValueTask<int> SendAsync(ReadOnlyMemory<byte> buffer);
ValueTask<int> ReceiveAsync(Memory<byte> buffer);
}Direct Request Reply
We have received quite a few reports about JetStream publish and other operations timing out under certain scenarios. Even though we suspect at least in some of these cases there maybe a combination of mixing sync and async code leading to thread pool issues and current request reply implementation relying on a single muxed subscription channel potentially creating a bottleneck, we knew there was room for improvement. With this feature (which is not turned on by default) we are by passing the mux subscription channel and delivering replies directly (hence the name) which results in a performance boost of ~10% in response time and about 40% in reducing GC pressure. (#829)
var opts = new NatsOpts
{
RequestReplyMode = NatsRequestReplyMode.Direct, // Disabled by default
};
await using var connection = new NatsConnection(opts);Call for Testing
We invite you to test this new release in your applications with RequestReplyMode set to NatsRequestReplyMode.Direct. We’re particularly interested in feedback from developers who have experienced timeouts related to JetStream publishing.
New Contributors
- @aradalvand made their first contribution in #825
- @wolfkor made their first contribution in #826
Full Changelog: v2.5.15...v2.5.16
Download from NuGet
You can download the latest version from NuGet.