MassiveDotNet.WebSocket 0.4.1

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package MassiveDotNet.WebSocket --version 0.4.1
                    
NuGet\Install-Package MassiveDotNet.WebSocket -Version 0.4.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="MassiveDotNet.WebSocket" Version="0.4.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MassiveDotNet.WebSocket" Version="0.4.1" />
                    
Directory.Packages.props
<PackageReference Include="MassiveDotNet.WebSocket" />
                    
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 MassiveDotNet.WebSocket --version 0.4.1
                    
#r "nuget: MassiveDotNet.WebSocket, 0.4.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 MassiveDotNet.WebSocket@0.4.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=MassiveDotNet.WebSocket&version=0.4.1
                    
Install as a Cake Addin
#tool nuget:?package=MassiveDotNet.WebSocket&version=0.4.1
                    
Install as a Cake Tool

MassiveDotNet.WebSocket

WebSocket streaming client for the Massive market data platform (formerly Polygon.io), for .NET 10.

dotnet add package MassiveDotNet.WebSocket

Quick start

using MassiveDotNet.WebSocket;
using MassiveDotNet.WebSocket.Events;

await using MassiveStreamClient client = new(new MassiveStreamOptions { ApiKey = apiKey });
await using MassiveStockStream stream = await client.ConnectStocksAsync();

MassiveTopicSubscription<StockTrade> trades = await stream.SubscribeTradesAsync(["AAPL"]);

await foreach (StockTrade trade in trades)
{
    Console.WriteLine($"{trade.Ticker}  {trade.Price:N2} x {trade.Size}  at {trade.SipTimestamp}");
}

Six stock topics, each returning a MassiveTopicSubscription<T> over its own event type: SubscribeTradesAsync, SubscribeQuotesAsync, SubscribeSecondAggregatesAsync, SubscribeMinuteAggregatesAsync, SubscribeImbalancesAsync, SubscribeLimitUpLimitDownAsync.

Three things worth knowing

Topics are a typed enum, not a string. The server silently drops a topic code it does not recognise — no acknowledgement, no error — so a caller who mistyped a string would see a healthy connection producing nothing, indefinitely. Every subscribe is acknowledgement-counted for the same reason and throws MassiveStreamSubscriptionException when the server accepted fewer pairs than were asked for. When the server refuses out loud, the exception carries what it actually said.

A slow consumer drops the oldest event, and never blocks. Each topic owns one bounded buffer (1024 events by default). Every topic shares one socket, so a writer that waited would stall the read loop and cost you the topics that were keeping up. Drops are counted exactly on DroppedCount and raised as an event; the DI package bridges that count to ILogger.

A malformed field costs one event, not the connection. The wire occasionally sends a value the SDK's schema won't parse — a z value Utf8JsonReader refuses, say. That event is dropped and counted rather than thrown out of the read loop; because the connection is multiplexed, one bad field on one symbol used to take every topic sharing the socket down with it, this package included. It's counted exactly on MalformedCount and raised as MalformedObserved, carrying the JsonException so you can see what the wire actually sent; the DI package bridges that to ILogger too.

Reconnect is automatic, with backoff, and replays every subscription. If the replay's acknowledgements fall short, SubscriptionsLost names the pairs that went unanswered rather than leaving you with a connection that looks healthy.

An eviction says so. Massive closes a connection to make room for another one on the same key, and it announces that first — the only disconnect cause that does. Without it, the abort reads exactly like a slow consumer or a network drop, and you go looking at your own throughput when the real problem is a second process. EvictionCount and LastEvictionMessage carry the server's own words; read them from a Reconnected handler, since reconnect is on by default and an eviction normally ends in one. With reconnect off, Faulted carries a MassiveStreamEvictedException instead. The SDK reports and keeps reconnecting — what to do about the other process is your call.

Native AOT clean, hand-written event converters reading straight off Utf8JsonReader, and parsing a frame allocates nothing beyond the event itself.

Licensed MIT. Issues and source at github.com/jerbersoft/massivedotnet.

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.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on MassiveDotNet.WebSocket:

Package Downloads
MassiveDotNet.Extensions.DependencyInjection

Dependency injection and IHttpClientFactory integration for the MassiveDotNet SDK, for ASP.NET Core, the Generic Host, and any app with a service collection.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.4.2-ci.64 67 9/26/2026
0.4.1 117 9/24/2026
0.4.1-ci.59 53 9/24/2026
0.4.0 93 9/24/2026
0.4.0-ci.58 60 9/24/2026
0.4.0-ci.55 55 9/24/2026
0.4.0-ci.54 62 9/23/2026
0.4.0-ci.53 56 9/23/2026
0.4.0-ci.52 68 9/23/2026
0.4.0-ci.51 57 9/23/2026
0.4.0-ci.49 61 9/22/2026
0.3.0 92 9/22/2026
0.3.0-ci.48 58 9/22/2026
0.3.0-ci.47 67 9/22/2026
0.3.0-ci.46 79 9/9/2026
0.3.0-ci.45 73 9/9/2026
0.2.0 114 9/9/2026
0.2.0-ci.44 74 9/9/2026
0.2.0-ci.42 74 9/9/2026
0.2.0-ci.41 77 9/9/2026