mirror of
https://github.com/taigrr/nats.docs
synced 2025-01-18 04:03:23 -08:00
updating docs
This commit is contained in:
@@ -2462,7 +2462,7 @@
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"Developing a Client","level":"9.2.1","depth":2,"next":{"title":"NATS Cluster Protocol","level":"9.3","depth":1,"path":"nats_protocol/nats-server-protocol.md","ref":"nats_protocol/nats-server-protocol.md","articles":[]},"previous":{"title":"Client Protocol","level":"9.2","depth":1,"path":"nats_protocol/nats-protocol.md","ref":"nats_protocol/nats-protocol.md","articles":[{"title":"Developing a Client","level":"9.2.1","depth":2,"path":"nats_protocol/nats-client-dev.md","ref":"nats_protocol/nats-client-dev.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["prism","-sharing","-highlight","include-html","toggle-chapters","anchors"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{"lang":{"ascii":"markup","text":"markup"}},"include-html":{},"toggle-chapters":{},"anchors":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"The NATS Maintainers","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"NATS","gitbook":"*","description":"Administrative, developer and conceptual documentation for the NATS messaging system."},"file":{"path":"nats_protocol/nats-client-dev.md","mtime":"2019-06-05T22:32:07.014Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-06-05T22:32:29.333Z"},"basePath":"..","book":{"language":""}});
|
||||
gitbook.page.hasChanged({"page":{"title":"Developing a Client","level":"9.2.1","depth":2,"next":{"title":"NATS Cluster Protocol","level":"9.3","depth":1,"path":"nats_protocol/nats-server-protocol.md","ref":"nats_protocol/nats-server-protocol.md","articles":[]},"previous":{"title":"Client Protocol","level":"9.2","depth":1,"path":"nats_protocol/nats-protocol.md","ref":"nats_protocol/nats-protocol.md","articles":[{"title":"Developing a Client","level":"9.2.1","depth":2,"path":"nats_protocol/nats-client-dev.md","ref":"nats_protocol/nats-client-dev.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["prism","-sharing","-highlight","include-html","toggle-chapters","anchors"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{"lang":{"ascii":"markup","text":"markup"}},"include-html":{},"toggle-chapters":{},"anchors":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"The NATS Maintainers","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"NATS","gitbook":"*","description":"Administrative, developer and conceptual documentation for the NATS messaging system."},"file":{"path":"nats_protocol/nats-client-dev.md","mtime":"2019-06-05T22:32:07.014Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-06-07T14:58:58.173Z"},"basePath":"..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
@@ -2467,7 +2467,7 @@ PONG
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"Protocol Demo","level":"9.1","depth":1,"next":{"title":"Client Protocol","level":"9.2","depth":1,"path":"nats_protocol/nats-protocol.md","ref":"nats_protocol/nats-protocol.md","articles":[{"title":"Developing a Client","level":"9.2.1","depth":2,"path":"nats_protocol/nats-client-dev.md","ref":"nats_protocol/nats-client-dev.md","articles":[]}]},"previous":{"title":"Endpoints","level":"8.9.2","depth":2,"path":"nats_streaming/monitoring/endpoints.md","ref":"nats_streaming/monitoring/endpoints.md","articles":[]},"dir":"ltr"},"config":{"plugins":["prism","-sharing","-highlight","include-html","toggle-chapters","anchors"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{"lang":{"ascii":"markup","text":"markup"}},"include-html":{},"toggle-chapters":{},"anchors":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"The NATS Maintainers","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"NATS","gitbook":"*","description":"Administrative, developer and conceptual documentation for the NATS messaging system."},"file":{"path":"nats_protocol/nats-protocol-demo.md","mtime":"2019-06-04T21:00:44.332Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-06-05T22:32:29.333Z"},"basePath":"..","book":{"language":""}});
|
||||
gitbook.page.hasChanged({"page":{"title":"Protocol Demo","level":"9.1","depth":1,"next":{"title":"Client Protocol","level":"9.2","depth":1,"path":"nats_protocol/nats-protocol.md","ref":"nats_protocol/nats-protocol.md","articles":[{"title":"Developing a Client","level":"9.2.1","depth":2,"path":"nats_protocol/nats-client-dev.md","ref":"nats_protocol/nats-client-dev.md","articles":[]}]},"previous":{"title":"Endpoints","level":"8.9.2","depth":2,"path":"nats_streaming/monitoring/endpoints.md","ref":"nats_streaming/monitoring/endpoints.md","articles":[]},"dir":"ltr"},"config":{"plugins":["prism","-sharing","-highlight","include-html","toggle-chapters","anchors"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{"lang":{"ascii":"markup","text":"markup"}},"include-html":{},"toggle-chapters":{},"anchors":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"The NATS Maintainers","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"NATS","gitbook":"*","description":"Administrative, developer and conceptual documentation for the NATS messaging system."},"file":{"path":"nats_protocol/nats-protocol-demo.md","mtime":"2019-06-04T21:00:44.332Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-06-07T14:58:58.173Z"},"basePath":"..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
@@ -2591,7 +2591,7 @@ Connection closed by foreign host.
|
||||
<h4 id="syntax"><a name="syntax" class="plugin-anchor" href="#syntax"><i class="fa fa-link" aria-hidden="true"></i></a>Syntax</h4>
|
||||
<p><code>+OK</code></p>
|
||||
<p><code>-ERR <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>error</span> <span class="token attr-name">message</span><span class="token punctuation">></span></span></code></p>
|
||||
<p>Some protocol errors result in the server closing the connection. Upon recieving these errors, the connection is no longer valid and the client should clean up relevant resources. These errors include:</p>
|
||||
<p>Some protocol errors result in the server closing the connection. Upon receiving these errors, the connection is no longer valid and the client should clean up relevant resources. These errors include:</p>
|
||||
<ul>
|
||||
<li><code>-ERR 'Unknown Protocol Operation'</code>: Unknown protocol error</li>
|
||||
<li><code>-ERR 'Attempted To Connect To Route Port'</code>: Client attempted to connect to a route port instead of the client port</li>
|
||||
@@ -2655,7 +2655,7 @@ Connection closed by foreign host.
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"Client Protocol","level":"9.2","depth":1,"next":{"title":"Developing a Client","level":"9.2.1","depth":2,"path":"nats_protocol/nats-client-dev.md","ref":"nats_protocol/nats-client-dev.md","articles":[]},"previous":{"title":"Protocol Demo","level":"9.1","depth":1,"path":"nats_protocol/nats-protocol-demo.md","ref":"nats_protocol/nats-protocol-demo.md","articles":[]},"dir":"ltr"},"config":{"plugins":["prism","-sharing","-highlight","include-html","toggle-chapters","anchors"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{"lang":{"ascii":"markup","text":"markup"}},"include-html":{},"toggle-chapters":{},"anchors":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"The NATS Maintainers","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"NATS","gitbook":"*","description":"Administrative, developer and conceptual documentation for the NATS messaging system."},"file":{"path":"nats_protocol/nats-protocol.md","mtime":"2019-05-30T22:52:52.322Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-06-05T22:32:29.333Z"},"basePath":"..","book":{"language":""}});
|
||||
gitbook.page.hasChanged({"page":{"title":"Client Protocol","level":"9.2","depth":1,"next":{"title":"Developing a Client","level":"9.2.1","depth":2,"path":"nats_protocol/nats-client-dev.md","ref":"nats_protocol/nats-client-dev.md","articles":[]},"previous":{"title":"Protocol Demo","level":"9.1","depth":1,"path":"nats_protocol/nats-protocol-demo.md","ref":"nats_protocol/nats-protocol-demo.md","articles":[]},"dir":"ltr"},"config":{"plugins":["prism","-sharing","-highlight","include-html","toggle-chapters","anchors"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{"lang":{"ascii":"markup","text":"markup"}},"include-html":{},"toggle-chapters":{},"anchors":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"The NATS Maintainers","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"NATS","gitbook":"*","description":"Administrative, developer and conceptual documentation for the NATS messaging system."},"file":{"path":"nats_protocol/nats-protocol.md","mtime":"2019-06-07T14:58:27.248Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-06-07T14:58:58.173Z"},"basePath":"..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
@@ -2352,14 +2352,14 @@
|
||||
<section class="normal markdown-section">
|
||||
|
||||
<h2 id="nats-cluster-protocol"><a name="nats-cluster-protocol" class="plugin-anchor" href="#nats-cluster-protocol"><i class="fa fa-link" aria-hidden="true"></i></a>NATS Cluster Protocol</h2>
|
||||
<p>The NATS server clustering protocol describes the messages passed between NATS servers within a <a href="../nats_server/clustering.html">cluster</a> 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.</p>
|
||||
<p>The NATS server clustering protocol describes the protocols passed between NATS servers within a <a href="../nats_server/clustering.html">cluster</a> to share accounts, subscriptions, forward messages, and share cluster topology regarding new servers. It is a simple text-based protocol. Servers communicate with each other through a regular TCP/IP or TLS socket using a small set of protocol operations that are terminated by newline.</p>
|
||||
<p>The NATS server implements a <a href="https://youtu.be/ylRKac5kSOk?t=10m46s" target="_blank">zero allocation byte parser</a> that is fast and efficient.</p>
|
||||
<p>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.</p>
|
||||
<h2 id="nats-cluster-protocol-conventions"><a name="nats-cluster-protocol-conventions" class="plugin-anchor" href="#nats-cluster-protocol-conventions"><i class="fa fa-link" aria-hidden="true"></i></a>NATS Cluster protocol conventions</h2>
|
||||
<p><strong>Subject names and wildcards</strong>: 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 <code>_SYS.</code>, which is reserved for messages that are internally generated by a server.</p>
|
||||
<p><strong>Subject names and wildcards</strong>: The NATS cluster protocol has the same features and restrictions as the client with respect to subject names and wildcards. Clients are bound to a single account, however the cluster protocol handles all accounts.</p>
|
||||
<p><strong>Field Delimiters</strong>: The fields of NATS protocol messages are delimited by whitespace characters '<code>`' (space) or</code>\t` (tab).
|
||||
Multiple whitespace characters will be treated as a single field delimiter.</p>
|
||||
<p><strong>Newlines</strong>: Like other text-based protocols, NATS uses <code>CR</code> followed by <code>LF</code> (<code>CR+LF</code>, <code>\r\n</code>, <code>0x0D0A</code>) to terminate protocol messages. This newline sequence is also used to mark the beginning of the actual message payload in a <code>PUB</code> or <code>MSG</code> protocol message.</p>
|
||||
<p><strong>Newlines</strong>: Like other text-based protocols, NATS uses <code>CR</code> followed by <code>LF</code> (<code>CR+LF</code>, <code>\r\n</code>, <code>0x0D0A</code>) to terminate protocol messages. This newline sequence is also used to mark the beginning of the actual message payload in a <code>RMSG</code> protocol message.</p>
|
||||
<h2 id="nats-cluster-protocol-messages"><a name="nats-cluster-protocol-messages" class="plugin-anchor" href="#nats-cluster-protocol-messages"><i class="fa fa-link" aria-hidden="true"></i></a>NATS Cluster protocol messages</h2>
|
||||
<p>The following table briefly describes the NATS cluster protocol messages.
|
||||
As in the client protocol, the NATS protocol operation names are case insensitive, thus <code>SUB foo 1\r\n</code> and <code>sub foo 1\r\n</code> are equivalent.</p>
|
||||
@@ -2384,24 +2384,19 @@ As in the client protocol, the NATS protocol operation names are case insensitiv
|
||||
<td style="text-align:left">Sent to establish a route</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="#PUB"><code>PUB</code></a></td>
|
||||
<td style="text-align:left">Sending Server</td>
|
||||
<td style="text-align:left">Sent when a message is published by a client.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="#SUB"><code>SUB</code></a></td>
|
||||
<td><a href="#SUB"><code>RS+</code></a></td>
|
||||
<td style="text-align:left">All Servers</td>
|
||||
<td style="text-align:left">Subscribes to a subject on behalf of interested clients.</td>
|
||||
<td style="text-align:left">Subscribes to a subject for a given account on behalf of interested clients.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="#UNSUB"><code>UNSUB</code></a></td>
|
||||
<td><a href="#UNSUB"><code>RS-</code></a></td>
|
||||
<td style="text-align:left">All Servers</td>
|
||||
<td style="text-align:left">Unsubscribe (or auto-unsubscribe) from subject.</td>
|
||||
<td style="text-align:left">Unsubscribe (or auto-unsubscribe) from subject for a given account.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="#MSG"><code>MSG</code></a></td>
|
||||
<td style="text-align:left">Receiving Server</td>
|
||||
<td style="text-align:left">Delivers a message payload to a subscriber on the local server.</td>
|
||||
<td><a href="#MSG"><code>RMSG</code></a></td>
|
||||
<td style="text-align:left">Origin Server</td>
|
||||
<td style="text-align:left">Delivers a message for a given subject and account to another server.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="#PINGPONG"><code>PING</code></a></td>
|
||||
@@ -2414,9 +2409,9 @@ As in the client protocol, the NATS protocol operation names are case insensitiv
|
||||
<td style="text-align:left">PONG keep-alive response</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="#OKERR"><code>+OK/-ERR</code></a></td>
|
||||
<td><a href="#ERR"><code>-ERR</code></a></td>
|
||||
<td style="text-align:left">All Servers</td>
|
||||
<td style="text-align:left">Indicates a protocol error. Will cause the server to disconnect.</td>
|
||||
<td style="text-align:left">Indicates a protocol error. May cause the remote server to disconnect.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -2451,8 +2446,6 @@ As in the client protocol, the NATS protocol operation names are case insensitiv
|
||||
<p><code>CONNECT {["option_name":option_value],...}</code></p>
|
||||
<p>The valid options are as follows:</p>
|
||||
<ul>
|
||||
<li><code>verbose</code>: Turns on <a href="#OKERR"><code>+OK</code></a> protocol acknowledgements.</li>
|
||||
<li><code>pedantic</code>: Turns on additional strict format checking, e.g. for properly formed subjects</li>
|
||||
<li><code>tls_required</code>: Indicates whether the server requires an SSL connection.</li>
|
||||
<li><code>auth_token</code>: Authorization token</li>
|
||||
<li><code>user</code>: Connection username (if <code>auth_required</code> is set)</li>
|
||||
@@ -2463,81 +2456,44 @@ As in the client protocol, the NATS protocol operation names are case insensitiv
|
||||
</ul>
|
||||
<h4 id="example"><a name="example" class="plugin-anchor" href="#example"><i class="fa fa-link" aria-hidden="true"></i></a>Example</h4>
|
||||
<p>Here is an example from the default string from a server.</p>
|
||||
<p><code>CONNECT {"verbose":false,"pedantic":false,"tls_required":false,"name":"wt0vffeQyoDGMVBC2aKX0b"}\r\n</code></p>
|
||||
<p>Servers should set <code>verbose</code> to <code>false</code> by default. This means that other routed servers will not be sending an <code>+OK</code> payload back after the remote server ingested the message.</p>
|
||||
<h2 id="pub"><a name="pub" class="plugin-anchor" href="#pub"><i class="fa fa-link" aria-hidden="true"></i></a><a name="PUB"></a>PUB</h2>
|
||||
<p><code>CONNECT {"tls_required":false,"name":"wt0vffeQyoDGMVBC2aKX0b"}\r\n</code></p>
|
||||
<h2 id="rs"><a name="rs" class="plugin-anchor" href="#rs"><i class="fa fa-link" aria-hidden="true"></i></a><a name="SUB"></a>RS+</h2>
|
||||
<h4 id="description"><a name="description" class="plugin-anchor" href="#description"><i class="fa fa-link" aria-hidden="true"></i></a>Description</h4>
|
||||
<p>The <code>PUB</code> message publishes the message payload to the given subject name, optionally supplying a reply subject, to another server. 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.</p>
|
||||
<p><code>RS+</code> initiates a subscription to a subject on on a given account, optionally with a distributed queue group name and weighting factor.
|
||||
Note that queue subscriptions will use RS+ for increases and descreases to queue weight except when the weighting factor is 0.</p>
|
||||
<h4 id="syntax"><a name="syntax" class="plugin-anchor" href="#syntax"><i class="fa fa-link" aria-hidden="true"></i></a>Syntax</h4>
|
||||
<p><code>PUB <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>subject</span><span class="token punctuation">></span></span> [reply-to] <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>#bytes</span><span class="token punctuation">></span></span>\r\n[payload]\r\n</code></p>
|
||||
<p><strong>Subscription</strong>: <code>RS+ <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>account</span><span class="token punctuation">></span></span> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>subject</span><span class="token punctuation">></span></span>\r\n</code></p>
|
||||
<p><strong>Queue Subscription</strong>: <code>RS+ <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>account</span><span class="token punctuation">></span></span> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>subject</span><span class="token punctuation">></span></span> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>queue</span><span class="token punctuation">></span></span> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>weight</span><span class="token punctuation">></span></span>\r\n</code></p>
|
||||
<p>where:</p>
|
||||
<ul>
|
||||
<li><code>subject</code>: The destination subject to publish to</li>
|
||||
<li><code>reply-to</code>: The reply inbox subject that subscribers can use to send a response back to the publisher/requestor</li>
|
||||
<li><code>#bytes</code>: The payload size in bytes</li>
|
||||
<li><code>payload</code>: The message payload data</li>
|
||||
<li><code>account</code>: The account associated with the subject interest</li>
|
||||
<li><code>subject</code>: The subject</li>
|
||||
<li><code>queue</code>: Optional queue group name</li>
|
||||
<li><code>weight</code>: Optional queue group weight representing how much interest/subscribers</li>
|
||||
</ul>
|
||||
<h4 id="example"><a name="example" class="plugin-anchor" href="#example"><i class="fa fa-link" aria-hidden="true"></i></a>Example</h4>
|
||||
<p>To publish the string message payload "Hello NATS!" to subject FOO:</p>
|
||||
<p><code>PUB FOO 11\r\nHello NATS!\r\n</code></p>
|
||||
<p>To publish a request message "Knock Knock" to subject FRONT.DOOR with reply subject INBOX.22:</p>
|
||||
<p><code>PUB FRONT.DOOR INBOX.22 11\r\nKnock Knock\r\n</code></p>
|
||||
<p>To publish an empty message to subject NOTIFY:</p>
|
||||
<p><code>PUB NOTIFY 0\r\n\r\n</code></p>
|
||||
<h2 id="sub"><a name="sub" class="plugin-anchor" href="#sub"><i class="fa fa-link" aria-hidden="true"></i></a><a name="SUB"></a>SUB</h2>
|
||||
<h2 id="rs-"><a name="rs-" class="plugin-anchor" href="#rs-"><i class="fa fa-link" aria-hidden="true"></i></a><a name="UNSUB"></a>RS-</h2>
|
||||
<h4 id="description"><a name="description" class="plugin-anchor" href="#description"><i class="fa fa-link" aria-hidden="true"></i></a>Description</h4>
|
||||
<p><code>SUB</code> initiates a subscription to a subject, optionally joining a distributed queue group.</p>
|
||||
<p><code>RS-</code> unsubcribes from the specified subject on the given account. It is sent by a server when it no longer has interest in a given subject.</p>
|
||||
<h4 id="syntax"><a name="syntax" class="plugin-anchor" href="#syntax"><i class="fa fa-link" aria-hidden="true"></i></a>Syntax</h4>
|
||||
<p><strong>Basic Subscription</strong>: <code>SUB <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>subject</span><span class="token punctuation">></span></span> RSID:<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>cid</span><span class="token punctuation">></span></span>:<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>sid</span><span class="token punctuation">></span></span>\r\n</code></p>
|
||||
<p><strong>Queue Subscription</strong>: <code>SUB <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>subject</span><span class="token punctuation">></span></span> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>queue</span><span class="token punctuation">></span></span> QRSID:<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>cid</span><span class="token punctuation">></span></span>:<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>sid</span><span class="token punctuation">></span></span>\r\n</code></p>
|
||||
<p><strong>Subscription</strong>: <code>RS- <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>account</span><span class="token punctuation">></span></span> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>subject</span><span class="token punctuation">></span></span>\r\n</code></p>
|
||||
<p>where:</p>
|
||||
<ul>
|
||||
<li><code>subject</code>: The subject name to subscribe to</li>
|
||||
<li><code>queue</code>: If specified, the subscriber will join this queue group</li>
|
||||
<li><code>cid</code>: A 64bit unsigned integer representing the client connection</li>
|
||||
<li><code>sid</code>: A unique alphanumeric subscription ID representing the server's subscription</li>
|
||||
<li><code>account</code>: The account associated with the subject interest</li>
|
||||
<li><code>subject</code>: The subject</li>
|
||||
</ul>
|
||||
<h4 id="example"><a name="example" class="plugin-anchor" href="#example"><i class="fa fa-link" aria-hidden="true"></i></a>Example</h4>
|
||||
<p>To subscribe to the subject <code>FOO</code> with the local unique subject identifier of <code>1</code>, and the connection-unique subject identifier (sid) <code>1</code>:</p>
|
||||
<p><code>SUB FOO RSID:1:1\r\n</code></p>
|
||||
<p>To subscribe the current connection to the subject <code>BAR</code> as part of distribution queue group <code>G1</code> with local sid of <code>14</code>, and a client sid <code>44</code>:</p>
|
||||
<p><code>SUB BAR G1 QRSID:14:44\r\n</code></p>
|
||||
<h2 id="unsub"><a name="unsub" class="plugin-anchor" href="#unsub"><i class="fa fa-link" aria-hidden="true"></i></a><a name="UNSUB"></a>UNSUB</h2>
|
||||
<h2 id="rmsg"><a name="rmsg" class="plugin-anchor" href="#rmsg"><i class="fa fa-link" aria-hidden="true"></i></a><a name="MSG"></a>RMSG</h2>
|
||||
<h4 id="description"><a name="description" class="plugin-anchor" href="#description"><i class="fa fa-link" aria-hidden="true"></i></a>Description</h4>
|
||||
<p><code>UNSUB</code> unsubcribes the connection from the specified subject, or auto-unsubscribes after the specified number of messages has been received. It is sent by a server when one of it's clients unsubscribes.</p>
|
||||
<p>The <code>RMSG</code> protocol message delivers a message to another server.</p>
|
||||
<h4 id="syntax"><a name="syntax" class="plugin-anchor" href="#syntax"><i class="fa fa-link" aria-hidden="true"></i></a>Syntax</h4>
|
||||
<p><strong>Basic Subscription</strong>: <code>UNSUB <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>sid</span><span class="token punctuation">></span></span> RSID:<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>cid</span><span class="token punctuation">></span></span>:<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>sid</span><span class="token punctuation">></span></span> [max_msgs]\r\n</code></p>
|
||||
<p><strong>Queue Subscription</strong>: <code>UNSUB <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>sid</span><span class="token punctuation">></span></span> QRSID:<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>cid</span><span class="token punctuation">></span></span>:<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>sid</span><span class="token punctuation">></span></span> [max_msgs]\r\n</code></p>
|
||||
<p>where:</p>
|
||||
<ul>
|
||||
<li><code>sid</code>: The unique alphanumeric subscription ID of the subject to unsubscribe from</li>
|
||||
<li><code>max_msgs</code>: Number of messages to wait for before automatically unsubscribing</li>
|
||||
<li><code>cid</code>: A 64bit unsigned integer representing the client connection</li>
|
||||
<li><code>sid</code>: A unique alphanumeric subscription ID representing the server's subscription</li>
|
||||
</ul>
|
||||
<h4 id="example"><a name="example" class="plugin-anchor" href="#example"><i class="fa fa-link" aria-hidden="true"></i></a>Example</h4>
|
||||
<p>The following examples concern subject <code>FOO</code> which has been assigned an internal subscriber id of <code>5</code>, and a client sid of <code>1</code>. To unsubscribe from <code>FOO</code>:</p>
|
||||
<p><code>UNSUB RSID:5:1\r\n</code></p>
|
||||
<p>To auto-unsubscribe from <code>FOO</code> after 5 messages have been received:</p>
|
||||
<p><code>UNSUB RSID:1:1 5\r\n</code></p>
|
||||
<h2 id="msg"><a name="msg" class="plugin-anchor" href="#msg"><i class="fa fa-link" aria-hidden="true"></i></a><a name="MSG"></a>MSG</h2>
|
||||
<h4 id="description"><a name="description" class="plugin-anchor" href="#description"><i class="fa fa-link" aria-hidden="true"></i></a>Description</h4>
|
||||
<p>The <code>MSG</code> protocol message delivers a message from another server.</p>
|
||||
<h4 id="syntax"><a name="syntax" class="plugin-anchor" href="#syntax"><i class="fa fa-link" aria-hidden="true"></i></a>Syntax</h4>
|
||||
<p><code>MSG <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>subject</span><span class="token punctuation">></span></span> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>sid</span><span class="token punctuation">></span></span> [reply-to] <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>#bytes</span><span class="token punctuation">></span></span>\r\n[payload]\r\n</code></p>
|
||||
<p><code>RMSG <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>account</span><span class="token punctuation">></span></span> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>subject</span><span class="token punctuation">></span></span> [reply-to] <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>#bytes</span><span class="token punctuation">></span></span>\r\n[payload]\r\n</code></p>
|
||||
<p>where:</p>
|
||||
<ul>
|
||||
<li><code>account</code>: The account associated with the subject interest</li>
|
||||
<li><code>subject</code>: Subject name this message was received on</li>
|
||||
<li><code>sid</code>: The unique alphanumeric subscription ID of the subject</li>
|
||||
<li><code>reply-to</code>: The inbox subject on which the publisher is listening for responses</li>
|
||||
<li><code>reply-to</code>: The optional reply subject</li>
|
||||
<li><code>#bytes</code>: Size of the payload in bytes</li>
|
||||
<li><code>payload</code>: The message payload data</li>
|
||||
</ul>
|
||||
<h4 id="example"><a name="example" class="plugin-anchor" href="#example"><i class="fa fa-link" aria-hidden="true"></i></a>Example</h4>
|
||||
<p>The following message delivers a message from subject <code>FOO.BAR</code>:</p>
|
||||
<p><code>MSG FOO.BAR 9 11\r\nHello World\r\n</code></p>
|
||||
<p>Deliver the same message along with a reply inbox:</p>
|
||||
<p><code>MSG FOO.BAR 9 INBOX.34 11\r\nHello World\r\n</code></p>
|
||||
<h2 id="pingpong"><a name="pingpong" class="plugin-anchor" href="#pingpong"><i class="fa fa-link" aria-hidden="true"></i></a><a name="PINGPONG"></a>PING/PONG</h2>
|
||||
<h4 id="description"><a name="description" class="plugin-anchor" href="#description"><i class="fa fa-link" aria-hidden="true"></i></a>Description</h4>
|
||||
<p><code>PING</code> and <code>PONG</code> implement a simple keep-alive mechanism between servers. Once two servers establish a connection with each other, the NATS server will continuously send <code>PING</code> messages to other servers at a configurable interval. If another server fails to respond with a <code>PONG</code> message within the configured response interval, the server will terminate its connection. If your connection stays idle for too long, it is cut off.</p>
|
||||
@@ -2545,28 +2501,9 @@ As in the client protocol, the NATS protocol operation names are case insensitiv
|
||||
<h4 id="syntax"><a name="syntax" class="plugin-anchor" href="#syntax"><i class="fa fa-link" aria-hidden="true"></i></a>Syntax</h4>
|
||||
<p><code>PING\r\n</code>
|
||||
<code>PONG\r\n</code></p>
|
||||
<h2 id="okerr"><a name="okerr" class="plugin-anchor" href="#okerr"><i class="fa fa-link" aria-hidden="true"></i></a><a name="OKERR"></a>+OK/ERR</h2>
|
||||
<h2 id="err"><a name="err" class="plugin-anchor" href="#err"><i class="fa fa-link" aria-hidden="true"></i></a><a name="ERR"></a>-ERR</h2>
|
||||
<h4 id="description"><a name="description" class="plugin-anchor" href="#description"><i class="fa fa-link" aria-hidden="true"></i></a>Description</h4>
|
||||
<p>When the <code>verbose</code> connection option is set to <code>true</code> (the default value), the server acknowledges each well-formed protocol message with a <code>+OK</code> message. NATS servers set the <code>verbose</code> option to <code>false</code> using the <a href="#CONNECT">CONNECT</a> message</p>
|
||||
<p>The <code>-ERR</code> message is used by the server indicate a protocol, authorization, or other runtime connection error to another server. Most of these errors result in the server closing the connection.</p>
|
||||
<p>Handling of these errors usually has to be done asynchronously.</p>
|
||||
<h4 id="syntax"><a name="syntax" class="plugin-anchor" href="#syntax"><i class="fa fa-link" aria-hidden="true"></i></a>Syntax</h4>
|
||||
<p><code>+OK</code></p>
|
||||
<p><code>-ERR <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>error</span> <span class="token attr-name">message</span><span class="token punctuation">></span></span></code></p>
|
||||
<p>Protocol error messages which close the connection:</p>
|
||||
<ul>
|
||||
<li><code>-ERR 'Unknown Protocol Operation'</code>: Unknown protocol error</li>
|
||||
<li><code>-ERR 'Authorization Violation'</code>: Server failed to authenticate to another server with credentials specified in the <a href="#CONNECT">CONNECT</a> message.</li>
|
||||
<li><code>-ERR 'Authorization Timeout'</code>: Server took too long to authenticate to another server after establishing a connection (default 1 second)</li>
|
||||
<li><code>-ERR 'Parser Error'</code>: Cannot parse the protocol message sent by another server</li>
|
||||
<li><code>-ERR 'Stale Connection'</code>: PING/PONG interval expired.</li>
|
||||
<li><code>-ERR 'Slow Consumer'</code>: The other server's pending data size for the route connection has been exceeded. The default limit is time based, where data cannot be flushed within a two second write deadline.</li>
|
||||
<li><code>-ERR 'Maximum Payload Exceeded'</code>: Server attempted to publish a message with a payload size that exceeds the <code>max_payload</code> size configured on another server.</li>
|
||||
</ul>
|
||||
<p>Protocol error messages which do not close the connection:</p>
|
||||
<ul>
|
||||
<li><code>-ERR 'Invalid Subject'</code>: Server sent a malformed subject (e.g. <code>sub foo. 90</code>)</li>
|
||||
</ul>
|
||||
<p>The <code>-ERR</code> message is used by the server to indicate a protocol, authorization, or other runtime connection error to another server. Most of these errors result in the remote server closing the connection.</p>
|
||||
|
||||
|
||||
</section>
|
||||
@@ -2606,7 +2543,7 @@ As in the client protocol, the NATS protocol operation names are case insensitiv
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"NATS Cluster Protocol","level":"9.3","depth":1,"previous":{"title":"Developing a Client","level":"9.2.1","depth":2,"path":"nats_protocol/nats-client-dev.md","ref":"nats_protocol/nats-client-dev.md","articles":[]},"dir":"ltr"},"config":{"plugins":["prism","-sharing","-highlight","include-html","toggle-chapters","anchors"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{"lang":{"ascii":"markup","text":"markup"}},"include-html":{},"toggle-chapters":{},"anchors":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"The NATS Maintainers","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"NATS","gitbook":"*","description":"Administrative, developer and conceptual documentation for the NATS messaging system."},"file":{"path":"nats_protocol/nats-server-protocol.md","mtime":"2019-05-31T18:06:29.020Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-06-05T22:32:29.333Z"},"basePath":"..","book":{"language":""}});
|
||||
gitbook.page.hasChanged({"page":{"title":"NATS Cluster Protocol","level":"9.3","depth":1,"previous":{"title":"Developing a Client","level":"9.2.1","depth":2,"path":"nats_protocol/nats-client-dev.md","ref":"nats_protocol/nats-client-dev.md","articles":[]},"dir":"ltr"},"config":{"plugins":["prism","-sharing","-highlight","include-html","toggle-chapters","anchors"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{"lang":{"ascii":"markup","text":"markup"}},"include-html":{},"toggle-chapters":{},"anchors":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"The NATS Maintainers","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"NATS","gitbook":"*","description":"Administrative, developer and conceptual documentation for the NATS messaging system."},"file":{"path":"nats_protocol/nats-server-protocol.md","mtime":"2019-06-07T14:58:27.248Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-06-07T14:58:58.173Z"},"basePath":"..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user