NATS .NET Client  1.1.4
The NATS.io .NET C# Client
NATS.Client.Options Class Reference

Public Member Functions

void SetUserCredentials (string credentialsPath, string privateKeyPath)
 
void SetUserCredentials (string credentialsPath)
 
void SetUserCredentialHandlers (EventHandler< UserJWTEventArgs > userJWTEventHandler, EventHandler< UserSignatureEventArgs > userSignatureEventHandler)
 
void SetNkey (string publicNkey, EventHandler< UserSignatureEventArgs > userSignatureEventHandler)
 
void SetNkey (string publicNkey, string privateKeyPath)
 
void SetJWTEventHandlers (EventHandler< UserJWTEventArgs > JWTEventHandler, EventHandler< UserSignatureEventArgs > SignatureEventHandler)
 
void AddCertificate (string fileName)
 
void AddCertificate (X509Certificate2 certificate)
 
void SetReconnectJitter (int jitter, int tlsJitter)
 
override string ToString ()
 

Public Attributes

EventHandler< ConnEventArgsClosedEventHandler
 
EventHandler< ConnEventArgsServerDiscoveredEventHandler
 
EventHandler< ConnEventArgsDisconnectedEventHandler
 
EventHandler< ConnEventArgsReconnectedEventHandler
 
EventHandler< ErrEventArgsAsyncErrorEventHandler
 
EventHandler< ConnEventArgsLameDuckModeEventHandler
 
EventHandler< ReconnectDelayEventArgsReconnectDelayHandler
 
EventHandler< HeartbeatAlarmEventArgsHeartbeatAlarmEventHandler
 
EventHandler< UnhandledStatusEventArgsUnhandledStatusEventHandler
 
EventHandler< StatusEventArgsPullStatusWarningEventHandler
 
EventHandler< StatusEventArgsPullStatusErrorEventHandler
 
EventHandler< FlowControlProcessedEventArgsFlowControlProcessedEventHandler
 
RemoteCertificateValidationCallback TLSRemoteCertificationValidationCallback
 

Static Public Attributes

static int ReconnectForever = -1
 
static readonly int ReconnectBufferSizeUnbounded = 0
 
static readonly int ReconnectBufferDisabled = -1
 

Properties

string Url [get, set]
 
string[] Servers [get, set]
 
bool NoRandomize [get, set]
 
string Name [get, set]
 
bool Verbose [get, set]
 
bool Pedantic [get, set]
 
bool UseOldRequestStyle [get, set]
 
bool Secure [get, set]
 
ITCPConnection TCPConnection [get, set]
 
bool AllowReconnect [get, set]
 
int MaxReconnect [get, set]
 
int ReconnectWait [get, set]
 
int PingInterval [get, set]
 
int Timeout [get, set]
 
int MaxPingsOut [get, set]
 
int SubChannelLength [get, set]
 
long PendingMessageLimit [get, set]
 
long PendingBytesLimit [get, set]
 
string User [get, set]
 
string Password [set]
 
string Token [get, set]
 
string CustomInboxPrefix [get, set]
 
int SubscriberDeliveryTaskCount [get, set]
 
int SubscriptionBatchSize [get, set]
 
bool NoEcho [get, set]
 
bool IgnoreDiscoveredServers [get, set]
 
bool TlsFirst [get, set]
 
bool ClientSideLimitChecks [get, set]
 
int ReconnectBufferSize [get, set]
 
int ReconnectJitter [get]
 
int ReconnectJitterTLS [get]
 
bool CheckCertificateRevocation = true [get, set]
 

Detailed Description

This class is used to setup all NATs client options.

Member Function Documentation

◆ AddCertificate() [1/2]

void NATS.Client.Options.AddCertificate ( string  fileName)

Adds an X.509 certificate from a file for use with a secure connection.

Parameters
fileNamePath to the certificate file to add.
Exceptions
ArgumentNullExceptionfileName is null.
System.Security.Cryptography.CryptographicExceptionAn error with the certificate occurred. For example:
  • The certificate file does not exist.
  • The certificate is invalid.
  • The certificate's password is incorrect.

◆ AddCertificate() [2/2]

void NATS.Client.Options.AddCertificate ( X509Certificate2  certificate)

Adds an X.509 certificate for use with a secure connection.

Parameters
certificateAn X.509 certificate represented as an X509Certificate2 object.
Exceptions
ArgumentNullExceptioncertificate is null.
System.Security.Cryptography.CryptographicExceptionAn error with the certificate occurred. For example:
  • The certificate file does not exist.
  • The certificate is invalid.
  • The certificate's password is incorrect.

◆ SetJWTEventHandlers()

void NATS.Client.Options.SetJWTEventHandlers ( EventHandler< UserJWTEventArgs JWTEventHandler,
EventHandler< UserSignatureEventArgs SignatureEventHandler 
)

Sets a custom JWT Event Handler and Signature handler.

Parameters
JWTEventHandler
SignatureEventHandler

◆ SetNkey() [1/2]

void NATS.Client.Options.SetNkey ( string  publicNkey,
EventHandler< UserSignatureEventArgs userSignatureEventHandler 
)

SetNkey will set the public Nkey and the signature callback to sign the server nonce.

Parameters
publicNkeyThe User's public Nkey
userSignatureEventHandlerA User signature Event Handler to sign the server nonce.

◆ SetNkey() [2/2]

void NATS.Client.Options.SetNkey ( string  publicNkey,
string  privateKeyPath 
)

SetNkey will set the public Nkey and the signature callback to sign the server nonce.

Parameters
publicNkeyThe User's public Nkey
privateKeyPathA path to a file containing the private Nkey.

◆ SetReconnectJitter()

void NATS.Client.Options.SetReconnectJitter ( int  jitter,
int  tlsJitter 
)

Sets the the upper bound for a random delay in milliseconds added to ReconnectWait during a reconnect for clear and TLS connections.

Defaults are 100 ms and 1s for TLS.

See also
ReconnectDelayHandler, ReconnectJitter, ReconnectJitterTLS, ReconnectWait

◆ SetUserCredentialHandlers()

void NATS.Client.Options.SetUserCredentialHandlers ( EventHandler< UserJWTEventArgs userJWTEventHandler,
EventHandler< UserSignatureEventArgs userSignatureEventHandler 
)

SetUserJWT will set the callbacks to retrieve the user's JWT and the signature callback to sign the server nonce. This an the Nkey option are mutually exclusive.

Parameters
userJWTEventHandlerA User JWT Event Handler
userSignatureEventHandlerA User signature Event Handler

◆ SetUserCredentials() [1/2]

void NATS.Client.Options.SetUserCredentials ( string  credentialsPath)

Sets user credentials using the NATS 2.0 security scheme.

Parameters
credentialsPathA chained credentials file, e.g user.cred

◆ SetUserCredentials() [2/2]

void NATS.Client.Options.SetUserCredentials ( string  credentialsPath,
string  privateKeyPath 
)

Sets user credentials using the NATS 2.0 security scheme.

Parameters
credentialsPathA user JWT, e.g user.jwt
privateKeyPathPrivate Key file

◆ ToString()

override string NATS.Client.Options.ToString ( )

Returns a string representation of the value of this Options instance.

Returns
string value of this instance.

Member Data Documentation

◆ LameDuckModeEventHandler

EventHandler<ConnEventArgs> NATS.Client.Options.LameDuckModeEventHandler

Represents the method that will handle an event raised when the server notifies the connection that it entered lame duck mode.

A server in lame duck mode will gradually disconnect all its connections before shuting down. This is often used in deployments when upgrading NATS Servers.

◆ ReconnectBufferDisabled

readonly int NATS.Client.Options.ReconnectBufferDisabled = -1
static

Constant that disables the reconnect buffer.

See also
ReconnectBufferSize

◆ ReconnectBufferSizeUnbounded

readonly int NATS.Client.Options.ReconnectBufferSizeUnbounded = 0
static

Constant used to sets the reconnect buffer size to unbounded.

See also
ReconnectBufferSize

◆ ReconnectDelayHandler

EventHandler<ReconnectDelayEventArgs> NATS.Client.Options.ReconnectDelayHandler

Represents the optional method that is used to get from the user the desired delay the client should pause before attempting to reconnect again.

Note that this is invoked after the library tried the entire list of URLs and failed to reconnect. By default, the client will use the sum of ReconnectWait and a random value between zero and Options.ReconnectJitter or Options.ReconnectJitterTLS

◆ TLSRemoteCertificationValidationCallback

RemoteCertificateValidationCallback NATS.Client.Options.TLSRemoteCertificationValidationCallback

Overrides the default NATS RemoteCertificationValidationCallback.

The default callback simply checks if there were any protocol errors. Overriding this callback is useful during testing, or accepting self signed certificates.

Property Documentation

◆ CheckCertificateRevocation

bool NATS.Client.Options.CheckCertificateRevocation = true
getset

Get or set whether to check Certificate Revocation when connecting via TLS

See also
SslStream.AuthenticateAsClientAsync(string, X509CertificateCollection, System.Security.Authentication.SslProtocols, bool)

◆ PingInterval

int NATS.Client.Options.PingInterval
getset

Gets or sets the interval, in milliseconds, pings will be sent to the server.

Take care to coordinate this value with the server's interval.

◆ ReconnectBufferSize

int NATS.Client.Options.ReconnectBufferSize
getset

Gets or sets the buffer size of messages kept while busy reconnecting.

When reconnecting, the NATS client will hold published messages that will be flushed to the new server upon a successful reconnect. The default is buffer size is 8 MB. This buffering can be disabled.

See also
ReconnectBufferSizeUnbounded, ReconnectBufferDisabled

◆ ReconnectJitter

int NATS.Client.Options.ReconnectJitter
get

Get the the upper bound for a random delay added to ReconnectWait during a reconnect for connections.

See also
ReconnectDelayHandler, ReconnectJitterTLS, ReconnectWait, SetReconnectJitter(int, int)

◆ ReconnectJitterTLS

int NATS.Client.Options.ReconnectJitterTLS
get

Get the the upper bound for a random delay added to ReconnectWait during a reconnect for TLS connections.

See also
ReconnectDelayHandler, ReconnectJitter, SetReconnectJitter(int, int)

◆ Servers

string [] NATS.Client.Options.Servers
getset

Gets or sets the array of servers that the NATS client will connect to.

The individual URLs may contain username/password information.

◆ SubscriberDeliveryTaskCount

int NATS.Client.Options.SubscriberDeliveryTaskCount
getset

Gets or sets the number of long running tasks to deliver messages to asynchronous subscribers. The default is zero (0) indicating each asynchronous subscriber has its own channel and task created to deliver messages.

The default where each subscriber has a delivery task is very performant, but does not scale well when large numbers of subscribers are required in an application. Setting this value will limit the number of subscriber channels to the specified number of long running tasks. These tasks will process messages for ALL asynchronous subscribers rather than one task for each subscriber.
Delivery order by subscriber is still guaranteed. The shared message processing channels are still each bounded by the SubChannelLength option. Note, slow subscriber errors will flag the last subscriber processed in the tasks, which may not actually be the slowest subscriber.

◆ SubscriptionBatchSize

int NATS.Client.Options.SubscriptionBatchSize
getset

Gets or sets the batch size for calling subscription handlers.

When delivering messages to the subscriber, the batch size determines how many messages could be retrieved from the internal subscription queue at one time. This can allow higher performance from a single subscriber by avoiding the locking overhead of one-at-a-time retrieval from the queue.

◆ Url

string NATS.Client.Options.Url
getset

Gets or sets the url used to connect to the NATs server. Can be a comma delimited list, it will be turning into Servers

This may contain username/password information.

◆ UseOldRequestStyle

bool NATS.Client.Options.UseOldRequestStyle
getset

Gets or sets a value indicating whether or not the old request pattern should be used.

The old request pattern involved a separate subscription per request inbox. The new style (default) involves creating a single inbox subscription per connection, upon the first request, and mapping outbound requests over that one subscription.


The documentation for this class was generated from the following file: