Table of Contents

Property DrainSubscriptionsOnDispose

Namespace
NATS.Client.Core
Assembly
NATS.Client.Core.dll

DrainSubscriptionsOnDispose

When true, DisposeAsync() drains subscriptions and flushes the command writer before closing the socket. (default: false)

public bool DrainSubscriptionsOnDispose { get; init; }

Property Value

bool

Remarks

With the default (false), the socket is closed first, which means UNSUB and any pending writes (e.g. JetStream acks queued by a consume loop) are dropped. Enable to let subscriptions drain cleanly on dispose. Required for ConsumerDrainOnDisposeTimeout to be effective.

Drain mechanism: each subscription sends UNSUB, then a PING and waits for the PONG (bounded by DrainPingTimeout). Once the PONG arrives the server has processed UNSUB and the socket reader has delivered any messages the server sent before that, so completing the user channel afterwards won't drop in-flight messages. Subscriptions drain in parallel on connection dispose, so total dispose time is bounded by one round-trip plus the ConsumerDrainOnDisposeTimeout wait if set, not multiplied by the number of subscriptions.