diff --git a/content/documentation/internals/nats-protocol.md b/content/documentation/internals/nats-protocol.md index 7b8e979c..d396ed61 100644 --- a/content/documentation/internals/nats-protocol.md +++ b/content/documentation/internals/nats-protocol.md @@ -1,15 +1,15 @@ +++ -date = "2015-09-27" -title = "NATS Protocol" +date = "2018-06-12" +title = "NATS Client Protocol" category = "internals" [menu.main] - name = "NATS Protocol" + name = "NATS Client Protocol" weight = 1 identifier = "internals-nats-protocol" parent = "Internals" +++ -# NATS protocol +# NATS Client protocol The NATS wire protocol is a simple, text-based publish/subscribe style protocol. Clients connect to and communicate with `gnatsd` (the NATS server) through a regular TCP/IP socket using a small set of protocol operations that are terminated by newline. @@ -17,7 +17,7 @@ Unlike traditional messaging systems that use a binary message format that requi The NATS server implements a [zero allocation byte parser](https://youtu.be/ylRKac5kSOk?t=10m46s) that is fast and efficient. -## NATS protocol conventions +## NATS Client protocol conventions **Subject names**: Subject names, including reply subject (INBOX) names, are case-sensitive and must be non-empty alphanumeric strings with no embedded whitespace, and optionally token-delimited using the dot character (`.`), e.g.: @@ -41,7 +41,7 @@ Multiple whitespace characters will be treated as a single field delimiter. This newline sequence is also used to mark the beginning of the actual message payload in a `PUB` or `MSG` protocol message. -## NATS protocol messages +## NATS Client protocol messages The following table briefly describes the NATS protocol messages. NATS protocol operation names are case insensitive, thus `SUB foo 1\r\n` and `sub foo 1\r\n` are equivalent. diff --git a/content/documentation/internals/nats-server-protocol.md b/content/documentation/internals/nats-server-protocol.md index babb60e3..cd815e0c 100644 --- a/content/documentation/internals/nats-server-protocol.md +++ b/content/documentation/internals/nats-server-protocol.md @@ -1,25 +1,25 @@ +++ -date = "2016-08-24" -title = "NATS Server Protocol" +date = "2018-06-12" +title = "NATS Cluster Protocol" category = "internals" [menu.main] - name = "NATS Server Protocol" + name = "NATS Cluster Protocol" weight = 1 identifier = "internals-nats-server-protocol" parent = "Internals" +++ -# NATS Server clustering protocol +# NATS Cluster protocol The NATS server clustering protocol describes the messages passed between NATS servers within a [cluster](/documentation/server/gnatsd-cluster/) to share subscription state, forward messages, and share cluster topology. It is a simple, text-based publish/subscribe style protocol. Servers communicate with each other through a regular TCP/IP socket using a small set of protocol operations that are terminated by newline. The NATS server implements a [zero allocation byte parser](https://youtu.be/ylRKac5kSOk?t=10m46s) that is fast and efficient. -The NATS server clustering protocol is very similar to that of the NATS client protocol. In the context of a cluster, it can be helpful to visualize a server being a proxy operating on behalf of its connected clients, subscribing, unsubscribing, sending and receiving messages. +The NATS cluster protocol is very similar to that of the NATS client protocol. In the context of a cluster, it can be helpful to visualize a server being a proxy operating on behalf of its connected clients, subscribing, unsubscribing, sending and receiving messages. -## NATS Server protocol conventions +## NATS Cluster protocol conventions -**Subject names and wildcards**: The NATS server protocol has the same features and restrictions as the client with respect to subject names and wildcards, with one addition - a server can publish subjects prefixed with `_SYS.`, which is reserved for messages that are internally generated by a server. +**Subject names and wildcards**: The NATS cluster protocol has the same features and restrictions as the client with respect to subject names and wildcards, with one addition - a server can publish subjects prefixed with `_SYS.`, which is reserved for messages that are internally generated by a server. **Field Delimiters**: The fields of NATS protocol messages are delimited by whitespace characters '` `' (space) or `\t` (tab). Multiple whitespace characters will be treated as a single field delimiter. @@ -27,7 +27,7 @@ Multiple whitespace characters will be treated as a single field delimiter. **Newlines**: Like other text-based protocols, NATS uses `CR` followed by `LF` (`CR+LF`, `\r\n`, `0x0D0A`) to terminate protocol messages. This newline sequence is also used to mark the beginning of the actual message payload in a `PUB` or `MSG` protocol message. -## NATS Server protocol messages +## NATS Cluster protocol messages The following table briefly describes the NATS cluster protocol messages. As in the client protocol, the NATS protocol operation names are case insensitive, thus `SUB foo 1\r\n` and `sub foo 1\r\n` are equivalent. @@ -147,16 +147,16 @@ To publish an empty message to subject NOTIFY: ### Syntax -**Basic Subscription**: `SUB RSID::\r\n` +**Basic Subscription**: `SUB RSID::\r\n` -**Queue Subscription**: `SUB QRSID:\r\n` +**Queue Subscription**: `SUB QRSID::\r\n` where: * `subject`: The subject name to subscribe to * `queue`: If specified, the subscriber will join this queue group -* `ssid`: A unique alphanumeric subscription ID representing the server's internal subscription -* `sid`: A unique alphanumeric subscription ID representing the client's subscription. +* `cid`: A 64bit unsigned integer representing the client connection +* `sid`: A unique alphanumeric subscription ID representing the server's subscription ### Description @@ -176,16 +176,16 @@ To subscribe the current connection to the subject `BAR` as part of distribution ### Syntax -**Basic Subscription**: `UNSUB RSID:: [max_msgs]\r\n` +**Basic Subscription**: `UNSUB RSID:: [max_msgs]\r\n` -**Queue Subscription**: `UNSUB QRSID:: [max_msgs]\r\n` +**Queue Subscription**: `UNSUB QRSID:: [max_msgs]\r\n` where: * `sid`: The unique alphanumeric subscription ID of the subject to unsubscribe from * `max_msgs`: Number of messages to wait for before automatically unsubscribing -* `ssid`: A unique alphanumeric subscription ID representing the server's internal subscription -* `sid`: A unique alphanumeric subscription ID representing the client's subscription. +* `cid`: A 64bit unsigned integer representing the client connection +* `sid`: A unique alphanumeric subscription ID representing the server's subscription ### Description