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

Inherits NATS.Client.IConnectionFactory.

Public Member Functions

 ConnectionFactory ()
 
IConnection CreateConnection (string url, bool reconnectOnConnect=false)
 
IConnection CreateConnection (string url, string credentialsPath, bool reconnectOnConnect=false)
 
IConnection CreateConnection (string url, string jwt, string privateNkey, bool reconnectOnConnect=false)
 
IConnection CreateSecureConnection (string url, bool reconnectOnConnect=false)
 
IConnection CreateConnection (bool reconnectOnConnect=false)
 
IConnection CreateConnection (Options opts, bool reconnectOnConnect=false)
 
IEncodedConnection CreateEncodedConnection (bool reconnectOnConnect=false)
 
IEncodedConnection CreateEncodedConnection (string url, bool reconnectOnConnect=false)
 
IEncodedConnection CreateEncodedConnection (Options opts, bool reconnectOnConnect=false)
 

Static Public Member Functions

static Options GetDefaultOptions (string server=null)
 

Detailed Description

Provides factory methods to create connections to NATS Servers.

Member Function Documentation

◆ CreateConnection() [1/5]

IConnection NATS.Client.ConnectionFactory.CreateConnection ( bool  reconnectOnConnect = false)

Create a connection to the NATs server using the default options.

Parameters
reconnectOnConnectif true, the connection will treat the initial connection as any other and attempt reconnects on failure
Returns
An IConnection object connected to the NATS server.
Exceptions
NATSNoServersExceptionNo connection to a NATS Server could be established.
NATSConnectionExceptionA timeout occurred connecting to a NATS Server.-or-An exception was encountered while connecting to a NATS Server. See Exception.InnerException for more details.
See also
GetDefaultOptions

◆ CreateConnection() [2/5]

IConnection NATS.Client.ConnectionFactory.CreateConnection ( Options  opts,
bool  reconnectOnConnect = false 
)

Create a connection to a NATS Server defined by the given options.

Parameters
optsThe NATS client options to use for this connection.
reconnectOnConnectif true, the connection will treat the initial connection as any other and attempt reconnects on failure
Returns
An IConnection object connected to the NATS server.
Exceptions
NATSNoServersExceptionNo connection to a NATS Server could be established.
NATSConnectionExceptionA timeout occurred connecting to a NATS Server.-or-An exception was encountered while connecting to a NATS Server. See Exception.InnerException for more details.

◆ CreateConnection() [3/5]

IConnection NATS.Client.ConnectionFactory.CreateConnection ( string  url,
bool  reconnectOnConnect = false 
)

Attempt to connect to the NATS server referenced by url .

url can contain username/password semantics. Comma seperated arrays are also supported, e.g. "urlA, urlB".

Parameters
urlA string containing the URL (or URLs) to the NATS Server. See the Remarks section for more information.
reconnectOnConnectif true, the connection will treat the initial connection as any other and attempt reconnects on failure
Returns
An IConnection object connected to the NATS server.
Exceptions
NATSNoServersExceptionNo connection to a NATS Server could be established.
NATSConnectionExceptionA timeout occurred connecting to a NATS Server.-or-An exception was encountered while connecting to a NATS Server. See Exception.InnerException for more details.

◆ CreateConnection() [4/5]

IConnection NATS.Client.ConnectionFactory.CreateConnection ( string  url,
string  credentialsPath,
bool  reconnectOnConnect = false 
)

Attempt to connect to the NATS server referenced by url with NATS 2.0 credentials.

url Comma seperated arrays are also supported, e.g. "urlA, urlB".

Parameters
urlA string containing the URL (or URLs) to the NATS Server. See the Remarks section for more information.
credentialsPathThe full path to a chained credentials file.
reconnectOnConnectif true, the connection will treat the initial connection as any other and attempt reconnects on failure
Returns
An IConnection object connected to the NATS server.
Exceptions
NATSNoServersExceptionNo connection to a NATS Server could be established.
NATSConnectionExceptionA timeout occurred connecting to a NATS Server.-or-An exception was encountered while connecting to a NATS Server. See Exception.InnerException for more details.

◆ CreateConnection() [5/5]

IConnection NATS.Client.ConnectionFactory.CreateConnection ( string  url,
string  jwt,
string  privateNkey,
bool  reconnectOnConnect = false 
)

Attempt to connect to the NATS server referenced by url with NATS 2.0 credentials.

url Comma seperated arrays are also supported, e.g. "urlA, urlB".

Parameters
urlA string containing the URL (or URLs) to the NATS Server. See the Remarks section for more information.
jwtThe path to a user's public JWT credentials.
privateNkeyThe path to a file for user user's private Nkey seed.
reconnectOnConnectif true, the connection will treat the initial connection as any other and attempt reconnects on failure
Returns
An IConnection object connected to the NATS server.
Exceptions
NATSNoServersExceptionNo connection to a NATS Server could be established.
NATSConnectionExceptionA timeout occurred connecting to a NATS Server.-or-An exception was encountered while connecting to a NATS Server. See Exception.InnerException for more details.

◆ CreateEncodedConnection() [1/3]

IEncodedConnection NATS.Client.ConnectionFactory.CreateEncodedConnection ( bool  reconnectOnConnect = false)

Attempt to connect to the NATS server, with an encoded connection, using the default options.

Parameters
reconnectOnConnectif true, the connection will treat the initial connection as any other and attempt reconnects on failure
Returns
An IEncodedConnection object connected to the NATS server.
See also
GetDefaultOptions
Exceptions
NATSNoServersExceptionNo connection to a NATS Server could be established.
NATSConnectionExceptionA timeout occurred connecting to a NATS Server.-or-An exception was encountered while connecting to a NATS Server. See Exception.InnerException for more details.

◆ CreateEncodedConnection() [2/3]

IEncodedConnection NATS.Client.ConnectionFactory.CreateEncodedConnection ( Options  opts,
bool  reconnectOnConnect = false 
)

Attempt to connect to the NATS server, with an encoded connection, using the given options.

Parameters
optsThe NATS client options to use for this connection.
Returns
An IEncodedConnection object connected to the NATS server.
Parameters
reconnectOnConnectif true, the connection will treat the initial connection as any other and attempt reconnects on failure
Exceptions
NATSNoServersExceptionNo connection to a NATS Server could be established.
NATSConnectionExceptionA timeout occurred connecting to a NATS Server.-or-An exception was encountered while connecting to a NATS Server. See Exception.InnerException for more details.

◆ CreateEncodedConnection() [3/3]

IEncodedConnection NATS.Client.ConnectionFactory.CreateEncodedConnection ( string  url,
bool  reconnectOnConnect = false 
)

Attempt to connect to the NATS server, with an encoded connection, referenced by url .

url can contain username/password semantics. Comma seperated arrays are also supported, e.g. urlA, urlB.

Parameters
reconnectOnConnectif true, the connection will treat the initial connection as any other and attempt reconnects on failure
Parameters
urlA string containing the URL (or URLs) to the NATS Server. See the Remarks section for more information.
Returns
An IEncodedConnection object connected to the NATS server.
Exceptions
NATSNoServersExceptionNo connection to a NATS Server could be established.
NATSConnectionExceptionA timeout occurred connecting to a NATS Server.-or-An exception was encountered while connecting to a NATS Server. See Exception.InnerException for more details.

◆ CreateSecureConnection()

IConnection NATS.Client.ConnectionFactory.CreateSecureConnection ( string  url,
bool  reconnectOnConnect = false 
)

Attempt to connect to the NATS server using TLS referenced by url .

url can contain username/password semantics. Comma seperated arrays are also supported, e.g. urlA, urlB.

Parameters
urlA string containing the URL (or URLs) to the NATS Server. See the Remarks section for more information.
reconnectOnConnectif true, the connection will treat the initial connection as any other and attempt reconnects on failure
Returns
An IConnection object connected to the NATS server.
Exceptions
NATSNoServersExceptionNo connection to a NATS Server could be established.
NATSConnectionExceptionA timeout occurred connecting to a NATS Server.-or-An exception was encountered while connecting to a NATS Server. See Exception.InnerException for more details.

◆ GetDefaultOptions()

static Options NATS.Client.ConnectionFactory.GetDefaultOptions ( string  server = null)
static

Retrieves the default set of client options.

Parameters
serverOptionally set the server. Still can be set or overriden with Options.Url or Options.Servers properties
Returns
The default Options object for the NATS client.

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