mirror of
https://github.com/taigrr/nats.docs
synced 2025-01-18 04:03:23 -08:00
Gramarly
This commit is contained in:
@@ -1858,7 +1858,7 @@
|
||||
|
||||
<h2 id="nats-clients">NATS Clients</h2>
|
||||
<p>The nats-server doesn'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>> go get https://github.com/nats-io/go-nats-examples/tools/nats-pub
|
||||
> 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>> nats-sub ">"
|
||||
Listening on [>]
|
||||
</code></pre><p>Note that when the client connected, the server didn'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'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"><</span>ctrl</span><span class="token punctuation">></span></span>+c</code> the process running the server, and restart the server with the <code>-V</code> flag:</p>
|
||||
<pre class="language-"><code>> 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 [>]
|
||||
[29785] 2019/05/16 08:46:13.467099 [TRC] 127.0.0.1:49805 - cid:1 - <<- [CONNECT {"verbose":false,"pedantic":false,"tls_required":false,"name":"NATS Sample Subscriber","lang":"go","version":"1.7.0","protocol":1,"echo":true}]
|
||||
[29785] 2019/05/16 08:46:13.467200 [TRC] 127.0.0.1:49805 - cid:1 - <<- [PING]
|
||||
[29785] 2019/05/16 08:46:13.467206 [TRC] 127.0.0.1:49805 - cid:1 - ->> [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] : 'world'
|
||||
</code></pre><p>On the subscriber window you should see:</p>
|
||||
<pre class="language-"><code>[#1] Received on [hello]: 'world'
|
||||
</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'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"><</span>server</span><span class="token punctuation">></span></span>:<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>port</span><span class="token punctuation">></span></span></code> and <code>tls://<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>server</span><span class="token punctuation">></span></span>:<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>port</span><span class="token punctuation">></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'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"><</span>server</span><span class="token punctuation">></span></span>:<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>port</span><span class="token punctuation">></span></span></code> and <code>tls://<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>server</span><span class="token punctuation">></span></span>:<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>port</span><span class="token punctuation">></span></span></code>. URLs with a <code>tls</code> protocol sport a secured TLS connection.</p>
|
||||
<pre class="language-"><code>> nats-sub -s nats://server:port ">"
|
||||
</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>> nats-sub -s nats://demo.nats.io ">"
|
||||
@@ -1943,7 +1943,7 @@ Published [hello] : 'world'
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user