Protocol messages

NATS.InfoType

A client will need to start as a plain TCP connection, then when the server accepts a connection from the client, it will send information about itself, the configuration and security requirements necessary for the client to successfully authenticate with the server and exchange messages. When using the updated client protocol (see CONNECT below), INFO messages can be sent anytime by the server. This means clients with that protocol level need to be able to asynchronously handle INFO messages.

  • server_id::String: The unique identifier of the NATS server.

  • server_name::String: The name of the NATS server.

  • version::String: The version of NATS.

  • go::String: The version of golang the NATS server was built with.

  • host::String: The IP address used to start the NATS server, by default this will be 0.0.0.0 and can be configured with -client_advertise host:port.

  • port::Int64: The port number the NATS server is configured to listen on.

  • headers::Bool: Whether the server supports headers.

  • max_payload::Int64: Maximum payload size, in bytes, that the server will accept from the client.

  • proto::Int64: An integer indicating the protocol version of the server. The server version 1.2.0 sets this to 1 to indicate that it supports the "Echo" feature.

  • client_id::Union{Nothing, UInt64}: The internal client identifier in the server. This can be used to filter client connections in monitoring, correlate with error logs, etc...

  • auth_required::Union{Nothing, Bool}: If this is true, then the client should try to authenticate upon connect.

  • tls_required::Union{Nothing, Bool}: If this is true, then the client must perform the TLS/1.2 handshake. Note, this used to be ssl_required and has been updated along with the protocol from SSL to TLS.

  • tls_verify::Union{Nothing, Bool}: If this is true, the client must provide a valid certificate during the TLS handshake.

  • tls_available::Union{Nothing, Bool}: If this is true, the client can provide a valid certificate during the TLS handshake.

  • connect_urls::Union{Nothing, Vector{String}}: List of server urls that a client can connect to.

  • ws_connect_urls::Union{Nothing, Vector{String}}: List of server urls that a websocket client can connect to.

  • ldm::Union{Nothing, Bool}: If the server supports Lame Duck Mode notifications, and the current server has transitioned to lame duck, ldm will be set to true.

  • git_commit::Union{Nothing, String}: The git hash at which the NATS server was built.

  • jetstream::Union{Nothing, Bool}: Whether the server supports JetStream.

  • ip::Union{Nothing, String}: The IP of the server.

  • client_ip::Union{Nothing, String}: The IP of the client.

  • nonce::Union{Nothing, String}: The nonce for use in CONNECT.

  • cluster::Union{Nothing, String}: The name of the cluster.

  • domain::Union{Nothing, String}: The configured NATS domain of the server.

source
NATS.ConnectType

The CONNECT message is the client version of the INFO message. Once the client has established a TCP/IP socket connection with the NATS server, and an INFO message has been received from the server, the client may send a CONNECT message to the NATS server to provide more information about the current connection as well as security information.

  • verbose::Bool: Turns on +OK protocol acknowledgements.

  • pedantic::Bool: Turns on additional strict format checking, e.g. for properly formed subjects.

  • tls_required::Bool: Indicates whether the client requires SSL connection.

  • auth_token::Union{Nothing, String}: Client authorization token.

  • user::Union{Nothing, String}: Connection username.

  • pass::Union{Nothing, String}: Connection password.

  • name::Union{Nothing, String}: Client name.

  • lang::String: The implementation language of the client.

  • version::String: The version of the client.

  • protocol::Union{Nothing, Int64}: Sending 0 (or absent) indicates client supports original protocol. Sending 1 indicates that the client supports dynamic reconfiguration of cluster topology changes by asynchronously receiving INFO messages with known servers it can reconnect to.

  • echo::Union{Nothing, Bool}: If set to false, the server (version 1.2.0+) will not send originating messages from this connection to its own subscriptions. Clients should set this to false only for server supporting this feature, which is when proto in the INFO protocol is set to at least 1.

  • sig::Union{Nothing, String}: In case the server has responded with a nonce on INFO, then a NATS client must use this field to reply with the signed nonce.

  • jwt::Union{Nothing, String}: The JWT that identifies a user permissions and account.

  • no_responders::Union{Nothing, Bool}: Enable quick replies for cases where a request is sent to a topic with no responders.

  • headers::Union{Nothing, Bool}: Whether the client supports headers.

  • nkey::Union{Nothing, String}: The public NKey to authenticate the client. This will be used to verify the signature (sig) against the nonce provided in the INFO message.

source
NATS.PubType

The PUB message publishes the message payload to the given subject name, optionally supplying a reply subject. If a reply subject is supplied, it will be delivered to eligible subscribers along with the supplied payload. Note that the payload itself is optional. To omit the payload, set the payload size to 0, but the second CRLF is still required.

The HPUB message is the same as PUB but extends the message payload to include NATS headers. Note that the payload itself is optional. To omit the payload, set the total message size equal to the size of the headers. Note that the trailing CR+LF is still required.

  • subject::String: The destination subject to publish to.

  • reply_to::Union{Nothing, String}: The reply subject that subscribers can use to send a response back to the publisher/requestor.

  • headers_length::Int64: Length of headers data inside payload

  • payload::Vector{UInt8}: Optional headers (NATS/1.0␍␊ followed by one or more name: value pairs, each separated by ␍␊) followed by payload data.

source
NATS.SubType

SUB initiates a subscription to a subject, optionally joining a distributed queue group.

  • subject::String: The subject name to subscribe to.

  • queue_group::Union{Nothing, String}: If specified, the subscriber will join this queue group.

  • sid::Int64: A unique alphanumeric subscription ID, generated by the client.

source
NATS.UnsubType

UNSUB unsubscribes the connection from the specified subject, or auto-unsubscribes after the specified number of messages has been received.

  • sid::Int64: The unique alphanumeric subscription ID of the subject to unsubscribe from.

  • max_msgs::Union{Nothing, Int64}: A number of messages to wait for before automatically unsubscribing.

source
NATS.MsgType

The MSG protocol message is used to deliver an application message to the client.

The HMSG message is the same as MSG, but extends the message payload with headers. See also ADR-4 NATS Message Headers.

  • subject::String: Subject name this message was received on.

  • sid::Int64: The unique alphanumeric subscription ID of the subject.

  • reply_to::Union{Nothing, String}: The subject on which the publisher is listening for responses.

  • headers_length::Int64: Length of headers data inside payload

  • payload::AbstractVector{UInt8}: Optional headers (NATS/1.0␍␊ followed by one or more name: value pairs, each separated by ␍␊) followed by payload data.

source
NATS.PingType

PING and PONG implement a simple keep-alive mechanism between client and server.

source
NATS.PongType

PING and PONG implement a simple keep-alive mechanism between client and server.

source
NATS.ErrType

The -ERR message is used by the server indicate a protocol, authorization, or other runtime connection error to the client. Most of these errors result in the server closing the connection.

  • message::String: Error message.
source
NATS.OkType

When the verbose connection option is set to true (the default value), the server acknowledges each well-formed protocol message from the client with a +OK message.

source