1
0
mirror of https://github.com/taigrr/nats.docs synced 2025-01-18 04:03:23 -08:00
This commit is contained in:
Alberto Ricart
2019-05-20 17:51:27 -05:00
parent a1c12370c2
commit 5da9b66f5e
133 changed files with 246 additions and 249 deletions

View File

@@ -1858,7 +1858,7 @@
<h2 id="nats-clients">NATS Clients</h2>
<p>The nats-server doesn&apos;t come bundled with any clients. But most client libraries come with tools that allow you to publish, subscribe, send requests and reply messages.</p>
<p>If you have a client library installed you can try using a bundled client. Otherwise you can easily install some clients.</p>
<p>If you have a client library installed, you can try using a bundled client. Otherwise, you can easily install some clients.</p>
<h3 id="if-you-have-go-installed">If you have Go installed:</h3>
<pre class="language-"><code>&gt; go get https://github.com/nats-io/go-nats-examples/tools/nats-pub
&gt; go get https://github.com/nats-io/go-nats-examples/tools/nats-sub
@@ -1872,10 +1872,10 @@
[29670] 2019/05/16 08:45:59.837161 [INF] Listening for client connections on 0.0.0.0:4222
[29670] 2019/05/16 08:45:59.837168 [INF] Server id is NAYH35Q7ROQHLQ3K565JR4OPTJGO5EK4FJX6KX5IHHEPLQBRSYVWI2NO
[29670] 2019/05/16 08:45:59.837170 [INF] Server is ready
</code></pre><p>On another terminal start session start a subscriber:</p>
</code></pre><p>On another terminal session start a subscriber:</p>
<pre class="language-"><code>&gt; nats-sub &quot;&gt;&quot;
Listening on [&gt;]
</code></pre><p>Note that when the client connected, the server didn&apos;t log anything interesting because server output is fairly quiet unless something interesting happens.</p>
</code></pre><p>Note that when the client connected, the server didn&apos;t log anything interesting because server output is relatively quiet unless something interesting happens.</p>
<p>To make the server output more lively, you can specify the <code>-V</code> flag to enable logging of server protocol tracing messages. Go ahead and <code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>ctrl</span><span class="token punctuation">&gt;</span></span>+c</code> the process running the server, and restart the server with the <code>-V</code> flag:</p>
<pre class="language-"><code>&gt; nats-server -V
[29785] 2019/05/16 08:46:12.731278 [INF] Starting nats-server version 2.0.0
@@ -1886,7 +1886,7 @@ Listening on [&gt;]
[29785] 2019/05/16 08:46:13.467099 [TRC] 127.0.0.1:49805 - cid:1 - &lt;&lt;- [CONNECT {&quot;verbose&quot;:false,&quot;pedantic&quot;:false,&quot;tls_required&quot;:false,&quot;name&quot;:&quot;NATS Sample Subscriber&quot;,&quot;lang&quot;:&quot;go&quot;,&quot;version&quot;:&quot;1.7.0&quot;,&quot;protocol&quot;:1,&quot;echo&quot;:true}]
[29785] 2019/05/16 08:46:13.467200 [TRC] 127.0.0.1:49805 - cid:1 - &lt;&lt;- [PING]
[29785] 2019/05/16 08:46:13.467206 [TRC] 127.0.0.1:49805 - cid:1 - -&gt;&gt; [PONG]
</code></pre><p>If you had created a subscriber, you should notice output on the subscriber telling you that it diesconnected, and reconnected. The server output above is more interesting. You can see the subscriber send a <code>CONNECT</code> protocol message, and a <code>PING</code> which was responded to by the server with a <code>PONG</code>.</p>
</code></pre><p>If you had created a subscriber, you should notice output on the subscriber telling you that it disconnected, and reconnected. The server output above is more interesting. You can see the subscriber send a <code>CONNECT</code> protocol message and a <code>PING</code> which was responded to by the server with a <code>PONG</code>.</p>
<blockquote>
<p>You can learn more about the <a href="../nats_protocol/nats-protocol.html">NATS protocol here</a>, but more intersting than the protocol description is <a href="../nats_protocol/nats-protocol-demo.html">an interactive demo</a>.</p>
</blockquote>
@@ -1896,7 +1896,7 @@ Published [hello] : &apos;world&apos;
</code></pre><p>On the subscriber window you should see:</p>
<pre class="language-"><code>[#1] Received on [hello]: &apos;world&apos;
</code></pre><h3 id="testing-against-a-remote-server">Testing Against a Remote Server</h3>
<p>If the NATS server was running in a different machine or a different port, you&apos;ll have to specify that to the client by specifying a <em>NATS URL</em>. NATS urls take the form of: <code>nats://<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>server</span><span class="token punctuation">&gt;</span></span>:<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>port</span><span class="token punctuation">&gt;</span></span></code> and <code>tls://<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>server</span><span class="token punctuation">&gt;</span></span>:<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>port</span><span class="token punctuation">&gt;</span></span></code>. URLs with a <code>tls</code> protocol sport a secured TLS connection.</p>
<p>If the NATS server were running in a different machine or a different port, you&apos;d have to specify that to the client by specifying a <em>NATS URL</em>. NATS URLs take the form of: <code>nats://<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>server</span><span class="token punctuation">&gt;</span></span>:<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>port</span><span class="token punctuation">&gt;</span></span></code> and <code>tls://<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>server</span><span class="token punctuation">&gt;</span></span>:<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>port</span><span class="token punctuation">&gt;</span></span></code>. URLs with a <code>tls</code> protocol sport a secured TLS connection.</p>
<pre class="language-"><code>&gt; nats-sub -s nats://server:port &quot;&gt;&quot;
</code></pre><p>If you want to try on a remote server, the NATS team maintains a demo server you can reach at <code>demo.nats.io</code>.</p>
<pre class="language-"><code>&gt; nats-sub -s nats://demo.nats.io &quot;&gt;&quot;
@@ -1943,7 +1943,7 @@ Published [hello] : &apos;world&apos;
<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"Clients","level":"2.3","depth":1,"next":{"title":"Flags","level":"2.4","depth":1,"path":"nats_server/flags.md","ref":"nats_server/flags.md","articles":[]},"previous":{"title":"Window Service","level":"2.2.1","depth":2,"path":"nats_server/windows_srv.md","ref":"nats_server/windows_srv.md","articles":[]},"dir":"ltr"},"config":{"plugins":["prism","-highlight","include-html","toggle-chapters"],"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":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"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_server/clients.md","mtime":"2019-05-16T14:42:57.087Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-05-20T22:00:46.477Z"},"basePath":"..","book":{"language":""}});
gitbook.page.hasChanged({"page":{"title":"Clients","level":"2.3","depth":1,"next":{"title":"Flags","level":"2.4","depth":1,"path":"nats_server/flags.md","ref":"nats_server/flags.md","articles":[]},"previous":{"title":"Window Service","level":"2.2.1","depth":2,"path":"nats_server/windows_srv.md","ref":"nats_server/windows_srv.md","articles":[]},"dir":"ltr"},"config":{"plugins":["prism","-highlight","include-html","toggle-chapters"],"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":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"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_server/clients.md","mtime":"2019-05-20T22:25:26.961Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-05-20T22:49:57.562Z"},"basePath":"..","book":{"language":""}});
});
</script>
</div>