NexNet 0.19.1

dotnet add package NexNet --version 0.19.1
                    
NuGet\Install-Package NexNet -Version 0.19.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NexNet" Version="0.19.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NexNet" Version="0.19.1" />
                    
Directory.Packages.props
<PackageReference Include="NexNet" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NexNet --version 0.19.1
                    
#r "nuget: NexNet, 0.19.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package NexNet@0.19.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NexNet&version=0.19.1
                    
Install as a Cake Addin
#tool nuget:?package=NexNet&version=0.19.1
                    
Install as a Cake Tool

NexNet Action Workflow

Real-time bidirectional networking for .NET. Source-generated hubs and proxies with zero reflection, multiple transports, and full AOT compatibility.

Documentation | API Reference


Packages

Name NuGet Description
NexNet NexNet Core library for server and client communication.
NexNet.Generator NexNet.Generator Source generator for hubs and proxies.
NexNet.Quic NexNet.Quic QUIC transport support.
NexNet.Asp NexNet.Asp ASP.NET Core integration for WebSocket and HttpSocket transports.

Why NexNet

NexNet is a networking framework for .NET that handles bidirectional communication between servers and clients. A Roslyn source generator emits all hub and proxy code at compile time — there is no reflection, no runtime code generation, and the result is fully NativeAOT compatible.

Interfaces define the contract between server and client. The generator produces strongly-typed proxies, invocation dispatchers, and serialization code. At runtime, connecting and invoking methods is straightforward: start a server, connect a client, and call methods through the proxy. NexNet handles reconnection, multiplexing, and transport abstraction.

Beyond RPC, NexNet provides synchronized collections that keep data in sync across server and clients, duplex pipes for raw byte streaming, typed channels for structured data streaming, and a declarative authorization system — all source-generated with the same zero-reflection approach.


Comparison

Capability NexNet SignalR gRPC
Source generated (no reflection) Yes No Yes (protobuf)
Bidirectional RPC Yes Yes (hub methods) Yes (streams)
Transport options 6 (UDS, TCP, TLS, QUIC, WS, HttpSocket) 3 (WS, SSE, Long Polling) 1 (HTTP/2)
Synchronized collections Yes No No
Duplex byte streaming Yes (pipes + channels) Yes (streams) Yes (streams)
Auto reconnection Yes Yes No
Built-in rate limiting Yes No No
NativeAOT compatible Yes No Partial
Session groups Yes Yes No
Interface versioning Yes (hash-locked) No Yes (protobuf)
ASP.NET integration Yes Native Native

Features

  • Source-generated hubs and proxies — all invocation code emitted at compile time; no reflection
  • Bidirectional method invocation — server-to-client and client-to-server calls with void, ValueTask, and ValueTask<T> returns
  • Synchronized collections — INexusList with server-to-client, bidirectional, and relay modes
  • Duplex pipes — bidirectional byte streaming with built-in flow control
  • Typed channels — INexusDuplexChannel<T> with IAsyncEnumerable support; primitive arrays use a compact bulk encoding
  • Serialization — NexNet MessagePack serializer (no external serializer dependency), generated formatters, Native AOT compatible
  • Session management — per-session hub instances, named groups for targeted broadcasting, automatic reconnection
  • Authentication — token-based connection authentication with IIdentity
  • Authorization — declarative [NexusAuthorize<TPermission>] with caching and compile-time diagnostics
  • Interface versioning — version hierarchy with HashLock validation and runtime enforcement
  • Six transports — UDS, TCP, TLS, QUIC, WebSocket, HttpSocket
  • ASP.NET Core integration — middleware with DI, authentication, and reverse proxy support
  • Rate limiting — per-IP limits, sliding windows, and automatic banning
  • Benchmarks — ~27,000 invocations/sec with minimal allocations

Quick Start

// Shared types
[NexusObject]
public class UserStatus
{
    [NexusKey(0)] public int UserId { get; set; }
    [NexusKey(1)] public string? Message { get; set; }
}

public interface IClientNexus
{
    ValueTask<string> GetUserName();
}
public interface IServerNexus
{
    ValueTask<UserStatus> GetStatus(int userId);
}

// Client nexus
[Nexus<IClientNexus, IServerNexus>(NexusType = NexusType.Client)]
partial class ClientNexus
{
    public ValueTask<string> GetUserName()
        => new("Bill");
}

// Server nexus
[Nexus<IServerNexus, IClientNexus>(NexusType = NexusType.Server)]
partial class ServerNexus
{
    public ValueTask<UserStatus> GetStatus(int userId)
        => new(new UserStatus { UserId = userId, Message = "Online" });
}

// Usage
var server = ServerNexus.CreateServer(serverConfig, () => new ServerNexus());
var client = ClientNexus.CreateClient(clientConfig, new ClientNexus());

await server.StartAsync();
await client.ConnectAsync();
var status = await client.Proxy.GetStatus(42);

The generator emits all hub and proxy classes, and a MessagePack formatter for every [NexusObject] type they use, at compile time. See Getting Started for the full walkthrough.


Benchmarks

BenchmarkDotNet v0.15.8, Windows 11 (10.0.26100.7462/24H2/2024Update/HudsonValley)
Intel Core i7-10700 CPU 2.90GHz, 1 CPU, 16 logical and 8 physical cores
.NET SDK 9.0.305
  [Host]     : .NET 9.0.9 (9.0.9, 9.0.925.41916), X64 RyuJIT x86-64-v3
  Job-FJSVHN : .NET 9.0.9 (9.0.9, 9.0.925.41916), X64 RyuJIT x86-64-v3

Platform=X64  Runtime=.NET 9.0
Method Mean Error StdDev Op/s Allocated
InvocationNoArgument 36.7 us 0.33 us 0.31 us 27,241.7 595 B
InvocationUnmanagedArgument 37.4 us 0.52 us 0.48 us 26,769.8 649 B
InvocationUnmanagedMultipleArguments 37.3 us 0.28 us 0.25 us 26,800.8 700 B
InvocationNoArgumentWithResult 36.9 us 0.35 us 0.32 us 27,095.2 633 B
InvocationWithDuplexPipe_Upload 51.8 us 0.60 us 0.51 us 19,295.4 14,951 B

Transport Selection Guide

Scenario Recommended Transport Reason
Same machine IPC Unix Domain Sockets Highest performance, no network overhead
Local network TCP Simple, reliable, fast
Internet/WAN TLS over TCP Secure, widely supported
Mobile/unstable networks QUIC Connection migration, better congestion control
Web applications WebSockets Browser compatibility, firewall-friendly
Reverse proxy setups HttpSockets Lower overhead than WebSockets

Dependencies

  • No external serializer: NexNet includes its own MessagePack serializer (NexNet.Serialization).
  • Internally packages Marc Gravell's Pipelines.Sockets.Unofficial with additional performance modifications for pipeline socket transports.
  • QUIC transport requires libmsquic on Linux. Windows Support

Samples

Sample Description
NexNetDemo Console app demonstrating invocations, channels, duplex pipes, collections, and API versioning
NexNetSample.Asp ASP.NET Core server and client with HttpSocket transport, bearer auth, duplex pipes, and collections
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on NexNet:

Package Downloads
NexNet.Quic

Quic transport protocol for NexNet.

NexNet.Asp

ASP.NET Core middleware for NexNet servers.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.19.1 0 11/1/2026
0.19.0 117 10/26/2026
0.18.0 115 10/20/2026
0.17.0 128 10/8/2026
0.16.0 140 10/3/2026
0.15.0 242 3/16/2026
0.14.1 230 12/30/2025
0.14.0 213 12/30/2025
0.13.0 298 12/22/2025
0.12.0 378 12/17/2025
0.11.0 304 8/10/2025
0.10.0 331 6/17/2025
0.9.1 298 5/2/2025
0.9.0 367 4/15/2025
0.8.1 312 2/18/2025
0.8.0 392 1/12/2024
0.7.0 325 1/11/2024
0.6.0 376 11/29/2023
0.5.0 348 10/23/2023
0.4.0 311 9/17/2023
Loading failed