Interface ConnectionOptions

Hierarchy

  • ConnectionOptions

Properties

authenticator?: Authenticator

When the server requires authentication, set an Authenticator. An authenticator is created automatically for username/password and token authentication configurations if user and pass or the token options are set.

debug?: boolean

When set to true the client will print protocol messages that it receives or sends to the server.

ignoreClusterUpdates?: boolean

When set to true, cluster information gossiped by the nats-server will not augment the lists of server(s) known by the client.

inboxPrefix?: string

A string prefix (must be a valid subject prefix) prepended to inboxes generated by client. This allows a client with limited subject permissions to specify a subject where requests can deliver responses.

maxPingOut?: number

Sets the maximum count of ping commands that can be awaiting a response before rasing a stale connection status StaleConnection notification status and initiating a reconnect.

See

pingInterval

maxReconnectAttempts?: number

Sets the maximum count of per-server reconnect attempts before giving up. Set to -1 to never give up.

Default

10

name?: string

Sets the client name. When set, the server monitoring pages will display this name when referring to this client.

noEcho?: boolean

When set to true, messages published by this client will not match this client's subscriptions, so the client is guaranteed to never receive self-published messages on a subject that it is listening on.

noRandomize?: boolean

If set to true, the client will not randomize its server connection list.

pass?: string

Sets the password for a client connection. Requires that the user option be set. See authenticator.

pedantic?: boolean

When set to true, the server may perform additional checks on protocol message requests. This option is only useful for NATS client development and shouldn't be used, as it affects server performance.

pingInterval?: number

Sets the number of milliseconds between client initiated ping commands. See maxPingOut.

Default

2 minutes.

port?: number

Sets the port number on the localhost (127.0.0.1) where the nats-server is running. This option is mutually exclusive with servers.

reconnect?: boolean

When set to true, the server will attempt to reconnect so long as maxReconnectAttempts doesn't prevent it.

Default

true

reconnectDelayHandler?: (() => number)

Type declaration

    • (): number
    • Set a function that dynamically determines the number of milliseconds that the client should wait for the next reconnect attempt.

      Returns number

reconnectJitter?: number

Set the upper bound for a random delay in milliseconds added to reconnectTimeWait.

Default

100 millis

reconnectJitterTLS?: number

Set the upper bound for a random delay in milliseconds added to reconnectTimeWait. This only affects TLS connections

Default

1000 millis

reconnectTimeWait?: number

Set the number of millisecods between reconnect attempts.

Default

2000 millis

servers?: string | string[]

Set the hostport(s) where the client should attempt to connect. This option is mutually exclusive with port.

Default

127.0.0.1:4222

timeout?: number

Sets the number of milliseconds the client should wait for a server handshake to be established.

Default

20000 millis

When set (can be an empty object), the client requires a secure connection. TlsOptions honored depend on the runtime. Consult the specific NATS javascript client GitHub repo/documentation. When set to null, the client should fail should not connect using TLS. In the case where TLS is available on the server a standard connection will be used. If TLS is required, the connection will fail.

token?: string

Set to a client authentication token. Note that these tokens are a specific authentication strategy on the nats-server. This option is mutually exclusive of user and pass. See authenticator.

user?: string

Sets the username for a client connection. Requires that the pass option be set. See authenticator.

verbose?: boolean

When set to true, the server will send response to all server commands. This option is only useful for NATS client development and shouldn't be used, as it affects server performance.

waitOnFirstConnect?: boolean

When set to true maxReconnectAttempts will not trigger until the client has established one connection.

Generated using TypeDoc