<trclass="memdesc:ga61d4a0cf2fbf7d13cc910e5a00c575be"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Creates a <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. <br/></td></tr>
<trclass="memdesc:ga3f7e760214417c7d87541ecb9ab5bea5"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets the URL to connect to. <br/></td></tr>
<trclass="memdesc:gacb7e964ae54b74d972d72e118b7b8bdf"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Set the list of servers to try to (re)connect to. <br/></td></tr>
<trclass="memdesc:ga5b99da7dd74aac3be962f323c3863d9e"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets the user name/password to use when not specified in the URL. <br/></td></tr>
<trclass="memdesc:gad58a5b9dabadeebda30e952ff7b39193"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets the token to use when not specified in the URL. <br/></td></tr>
<trclass="memdesc:ga23a3b1f022112e98ddccb18b247b4426"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets the tokenCb to use whenever a token is needed. <br/></td></tr>
<trclass="memdesc:gaabf8763b931dcf389c83fd95d760a413"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Indicate if the servers list should be randomized. <br/></td></tr>
<trclass="memdesc:ga17cd7fe41176cd98aca1184fa9352ad9"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets the (re)connect process timeout. <br/></td></tr>
<trclass="memdesc:ga2cd6563694a439b3949a31fd81103099"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Loads the trusted CA certificates from a file. <br/></td></tr>
<trclass="memdesc:gafb30794fc2ae74b9e0bd8fb609b901c8"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets the trusted CA certificates from memory. <br/></td></tr>
<trclass="memdesc:ga36943e2ba53d05407cdabc4e7e96484b"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Loads the certificate chain from a file, using the given key. <br/></td></tr>
<trclass="memdesc:gae98f0f9034e93941767ab1ae6eec2c0c"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets the client certificate and key. <br/></td></tr>
<trclass="memdesc:ga5698f020e8eb3e7440eb073fe08ef62c"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets the list of available ciphers. <br/></td></tr>
<trclass="memdesc:ga2b7f144b011d8ce62941b608a8f324f0"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets the list of available ciphers for TLSv1.3. <br/></td></tr>
<trclass="memdesc:ga0ba43ba9930df385e4781b12be9f2851"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets the server certificate's expected hostname. <br/></td></tr>
<trclass="memdesc:ga6f804ec44adc299989fe623570679da3"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Switch server certificate verification. <br/></td></tr>
<trclass="memitem:gaaff89c3f41627f4b2929dbc9b82d265b"id="r_gaaff89c3f41627f4b2929dbc9b82d265b"><tdclass="memItemLeft"align="right"valign="top"><aclass="el"href="nats_8h.html#a3bc1b3fe7f64083e60c7c3b93f205bad">NATS_EXTERN</a><aclass="el"href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a> </td><tdclass="memItemRight"valign="bottom"><aclass="el"href="group__opts_group.html#gaaff89c3f41627f4b2929dbc9b82d265b">natsOptions_SetMaxPingsOut</a> (<aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e">natsOptions</a> *opts, int maxPingsOut)</td></tr>
<trclass="memdesc:gaaff89c3f41627f4b2929dbc9b82d265b"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets the limit of outstanding <code>PING</code>s without corresponding <code>PONG</code>s. <br/></td></tr>
<trclass="memitem:ga1a3e3abfd7ddd8aff247df8f332bbda3"id="r_ga1a3e3abfd7ddd8aff247df8f332bbda3"><tdclass="memItemLeft"align="right"valign="top"><aclass="el"href="nats_8h.html#a3bc1b3fe7f64083e60c7c3b93f205bad">NATS_EXTERN</a><aclass="el"href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a> </td><tdclass="memItemRight"valign="bottom"><aclass="el"href="group__opts_group.html#ga1a3e3abfd7ddd8aff247df8f332bbda3">natsOptions_SetIOBufSize</a> (<aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e">natsOptions</a> *opts, int ioBufSize)</td></tr>
<trclass="memdesc:ga1a3e3abfd7ddd8aff247df8f332bbda3"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets the size of the internal read/write buffers. <br/></td></tr>
<trclass="memdesc:ga3d1d3cb2f2a0e23d27dd60e96d1cc91b"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Indicates if the connection will be allowed to reconnect. <br/></td></tr>
<trclass="memitem:gab54cd2719c0b64eebd6c7b83dd2908a0"id="r_gab54cd2719c0b64eebd6c7b83dd2908a0"><tdclass="memItemLeft"align="right"valign="top"><aclass="el"href="nats_8h.html#a3bc1b3fe7f64083e60c7c3b93f205bad">NATS_EXTERN</a><aclass="el"href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a> </td><tdclass="memItemRight"valign="bottom"><aclass="el"href="group__opts_group.html#gab54cd2719c0b64eebd6c7b83dd2908a0">natsOptions_SetMaxReconnect</a> (<aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e">natsOptions</a> *opts, int maxReconnect)</td></tr>
<trclass="memdesc:gab54cd2719c0b64eebd6c7b83dd2908a0"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets the maximum number of reconnect attempts. <br/></td></tr>
<trclass="memdesc:ga2730f4e16e318a2ef8de98dbf6ede807"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets the time between reconnect attempts. <br/></td></tr>
<trclass="memdesc:ga8f3df57ed8ae418d3ae6678ae5e2a5d2"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Set the upper bound of a random delay added to reconnect wait. <br/></td></tr>
<trclass="memdesc:ga3593165aa113d6736e0226ddc56b3e9d"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets the handler to invoke when the library needs to wait before the next reconnect attempts. <br/></td></tr>
<trclass="memitem:gaa0d4b7ece8477cb9879f0dafff3456a5"id="r_gaa0d4b7ece8477cb9879f0dafff3456a5"><tdclass="memItemLeft"align="right"valign="top"><aclass="el"href="nats_8h.html#a3bc1b3fe7f64083e60c7c3b93f205bad">NATS_EXTERN</a><aclass="el"href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a> </td><tdclass="memItemRight"valign="bottom"><aclass="el"href="group__opts_group.html#gaa0d4b7ece8477cb9879f0dafff3456a5">natsOptions_SetReconnectBufSize</a> (<aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e">natsOptions</a> *opts, int reconnectBufSize)</td></tr>
<trclass="memdesc:gaa0d4b7ece8477cb9879f0dafff3456a5"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets the size of the backing buffer used during reconnect. <br/></td></tr>
<trclass="memitem:ga95510436eee06f9992ded96a44795c40"id="r_ga95510436eee06f9992ded96a44795c40"><tdclass="memItemLeft"align="right"valign="top"><aclass="el"href="nats_8h.html#a3bc1b3fe7f64083e60c7c3b93f205bad">NATS_EXTERN</a><aclass="el"href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a> </td><tdclass="memItemRight"valign="bottom"><aclass="el"href="group__opts_group.html#ga95510436eee06f9992ded96a44795c40">natsOptions_SetMaxPendingMsgs</a> (<aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e">natsOptions</a> *opts, int maxPending)</td></tr>
<trclass="memdesc:ga95510436eee06f9992ded96a44795c40"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets the maximum number of pending messages per subscription. <br/></td></tr>
<trclass="memdesc:ga127ec7a8196b453947a7fa9a64096cbd"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets the error handler for asynchronous events. <br/></td></tr>
<trclass="memdesc:ga44410242e73134e5bb51ef27904a9253"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets the callback to be invoked when a connection to a server is permanently lost. <br/></td></tr>
<trclass="memdesc:gadc8dc0cedd91bda71d544f3dedc4a039"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets the callback to be invoked when the connection to a server is lost. <br/></td></tr>
<trclass="memdesc:ga26a48c8529fffa5f5d1a61c030979980"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets the callback to be invoked when the connection has reconnected. <br/></td></tr>
<trclass="memdesc:gab5baab507c974402ab0d8c5e8227ee65"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets the callback to be invoked when new servers are discovered. <br/></td></tr>
<trclass="memdesc:ga7e4172084520708b8c9f28e73174461c"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets if the library should ignore or not discovered servers. <br/></td></tr>
<trclass="memdesc:ga54dea2ffeb33779771652a7a14fc4adc"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets the callback to be invoked when server enters lame duck mode. <br/></td></tr>
<trclass="memdesc:gab09491bad908dedcb323c780280733ff"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets the external event loop and associated callbacks. <br/></td></tr>
<trclass="memdesc:gabf060c92648b50c069f0abe7cbb06f1c"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Switch on/off the use of a central message delivery thread pool. <br/></td></tr>
<trclass="memitem:ga7ca713c7532eff4d41a492e95b8822cf"id="r_ga7ca713c7532eff4d41a492e95b8822cf"><tdclass="memItemLeft"align="right"valign="top"><aclass="el"href="nats_8h.html#a3bc1b3fe7f64083e60c7c3b93f205bad">NATS_EXTERN</a><aclass="el"href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a> </td><tdclass="memItemRight"valign="bottom"><aclass="el"href="group__opts_group.html#ga7ca713c7532eff4d41a492e95b8822cf">natsOptions_IPResolutionOrder</a> (<aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e">natsOptions</a> *opts, int order)</td></tr>
<trclass="memdesc:ga7ca713c7532eff4d41a492e95b8822cf"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Dictates the order in which host name are resolved during connect. <br/></td></tr>
<trclass="memdesc:ga8f06568cc3319a5a0eef9f80282034ca"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets if Publish calls should send data right away. <br/></td></tr>
<trclass="memdesc:ga70aa85319933d78c0076cc862fa3e5a6"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Switches the use of old style requests. <br/></td></tr>
<trclass="memdesc:ga4f694b87039cedaa65cd25656b14d1a3"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets if connection receives its own messages. <br/></td></tr>
<trclass="memdesc:ga20946800d024b7089e73d63454d1c19f"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Indicates if initial connect failure should be retried or not. <br/></td></tr>
<trclass="memdesc:ga60117450fc1f7b6f81bab455aeed7515"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets the callbacks to fetch user JWT and sign server's nonce. <br/></td></tr>
<trclass="memdesc:ga59b47f7b7a19085cf8eaada9bfe5606e"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets the file(s) to use to fetch user JWT and seed required to sign nonce. <br/></td></tr>
<trclass="memdesc:ga5d3d4d1269dd289f93c56b8a1ddccd43"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets JWT handler and handler to sign nonce that uses seed. <br/></td></tr>
<trclass="memdesc:ga0290eac4665569c850468d9f00e246a0"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets the NKey public key and signature callback. <br/></td></tr>
<trclass="memdesc:ga696f02e0493c00d3c1eafff45b62b68e"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets the NKey public key and its seed file. <br/></td></tr>
<trclass="memdesc:ga192465163abb87ad48a843b45cdf9984"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Enable/Disable the "no responders" feature. <br/></td></tr>
<trclass="memitem:ga5acd292cdaeb63d3d7bd9bbc05513c8f"id="r_ga5acd292cdaeb63d3d7bd9bbc05513c8f"><tdclass="memItemLeft"align="right"valign="top"><aclass="el"href="nats_8h.html#a3bc1b3fe7f64083e60c7c3b93f205bad">NATS_EXTERN</a><aclass="el"href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a> </td><tdclass="memItemRight"valign="bottom"><aclass="el"href="group__opts_group.html#ga5acd292cdaeb63d3d7bd9bbc05513c8f">natsOptions_SetMessageBufferPadding</a> (<aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e">natsOptions</a> *opts, int paddingSize)</td></tr>
<trclass="memdesc:ga5acd292cdaeb63d3d7bd9bbc05513c8f"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Sets a custom padding when allocating buffer for incoming messages. <br/></td></tr>
<trclass="memdesc:ga93d8068cd6fff53b7f8e1c403db45eb9"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Destroys a <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. <br/></td></tr>
<p>Creates a <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. This object is used when one wants to set specific options prior to connecting to the <code>NATS Server</code>.</p>
<p>After making the appropriate natsOptions_Set calls, this object is passed to the <aclass="el"href="group__conn_mgt_group.html#ga740be1ba16a8570eb98ef6755ebf52ce"title="Connects to a NATS Server using the provided options.">natsConnection_Connect()</a> call, which will clone this object. After <aclass="el"href="group__conn_mgt_group.html#ga740be1ba16a8570eb98ef6755ebf52ce"title="Connects to a NATS Server using the provided options.">natsConnection_Connect()</a> returns, modifications to the options object will not affect the connection.</p>
<dlclass="section note"><dt>Note</dt><dd>The object needs to be destroyed when no longer needed.*</dd></dl>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="group__conn_mgt_group.html#ga740be1ba16a8570eb98ef6755ebf52ce"title="Connects to a NATS Server using the provided options.">natsConnection_Connect()</a></dd>
<dd>
<aclass="el"href="group__opts_group.html#ga93d8068cd6fff53b7f8e1c403db45eb9"title="Destroys a natsOptions object.">natsOptions_Destroy()</a></dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">newOpts</td><td>the location where store the pointer to the newly created <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<p>Sets the URL of the <code>NATS Server</code> the client should try to connect to. The URL can contain optional user name and password.</p>
<p>Some valid URLS:</p>
<ul>
<li>nats://localhost:4222</li>
<li>nats://user@localhost:4222</li>
<li>nats://user:password@localhost:4222</li>
</ul>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="group__opts_group.html#gacb7e964ae54b74d972d72e118b7b8bdf"title="Set the list of servers to try to (re)connect to.">natsOptions_SetServers</a></dd>
<dd>
<aclass="el"href="group__opts_group.html#ga5b99da7dd74aac3be962f323c3863d9e"title="Sets the user name/password to use when not specified in the URL.">natsOptions_SetUserInfo</a></dd>
<dd>
<aclass="el"href="group__opts_group.html#gad58a5b9dabadeebda30e952ff7b39193"title="Sets the token to use when not specified in the URL.">natsOptions_SetToken</a></dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">url</td><td>the string representing the URL the connection should use to connect to the server. </td></tr>
<p>This specifies a list of servers to try to connect (or reconnect) to. Note that if you call <aclass="el"href="group__opts_group.html#ga3f7e760214417c7d87541ecb9ab5bea5"title="Sets the URL to connect to.">natsOptions_SetURL()</a> too, the actual list will contain the one from <aclass="el"href="group__opts_group.html#ga3f7e760214417c7d87541ecb9ab5bea5"title="Sets the URL to connect to.">natsOptions_SetURL()</a> and the ones specified in this call.</p>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="group__opts_group.html#ga3f7e760214417c7d87541ecb9ab5bea5"title="Sets the URL to connect to.">natsOptions_SetURL</a></dd>
<dd>
<aclass="el"href="group__opts_group.html#ga5b99da7dd74aac3be962f323c3863d9e"title="Sets the user name/password to use when not specified in the URL.">natsOptions_SetUserInfo</a></dd>
<dd>
<aclass="el"href="group__opts_group.html#gad58a5b9dabadeebda30e952ff7b39193"title="Sets the token to use when not specified in the URL.">natsOptions_SetToken</a></dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">servers</td><td>the array of strings representing the server URLs. </td></tr>
<tr><tdclass="paramname">serversCount</td><td>the size of the array. </td></tr>
<p>Credentials are usually provided through the URL in the form: <code>nats://foo:bar@localhost:4222</code>.<br/>
Until now, you could specify URLs in two ways, with <aclass="el"href="group__opts_group.html#gacb7e964ae54b74d972d72e118b7b8bdf"title="Set the list of servers to try to (re)connect to.">natsOptions_SetServers</a> or <aclass="el"href="group__conn_mgt_group.html#gafb83c8d7970ba68be0e6c40c38cdfde4"title="Connects to a NATS Server using any of the URL from the given list.">natsConnection_ConnectTo</a>. The client library would connect (or reconnect) only to this given list of URLs, so if any of the server in the list required authentication, you were responsible for providing the appropriate credentials in the URLs.<br/>
<br/>
However, with cluster auto-discovery, the client library asynchronously receives URLs of servers in the cluster. These URLs do not contain any embedded credentials. <br/>
You need to use this function (or <aclass="el"href="group__opts_group.html#gad58a5b9dabadeebda30e952ff7b39193"title="Sets the token to use when not specified in the URL.">natsOptions_SetToken</a>) to instruct the client library to use those credentials when connecting to a server that requires authentication and for which there is no embedded credentials in the URL.</p>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="group__opts_group.html#gad58a5b9dabadeebda30e952ff7b39193"title="Sets the token to use when not specified in the URL.">natsOptions_SetToken</a></dd>
<dd>
<aclass="el"href="group__opts_group.html#ga3f7e760214417c7d87541ecb9ab5bea5"title="Sets the URL to connect to.">natsOptions_SetURL</a></dd>
<dd>
<aclass="el"href="group__opts_group.html#gacb7e964ae54b74d972d72e118b7b8bdf"title="Set the list of servers to try to (re)connect to.">natsOptions_SetServers</a></dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">user</td><td>the user name to send to the server during connect. </td></tr>
<tr><tdclass="paramname">password</td><td>the password to send to the server during connect. </td></tr>
<p>Tokens are usually provided through the URL in the form: <code>nats://mytoken@localhost:4222</code>.<br/>
Until now, you could specify URLs in two ways, with <aclass="el"href="group__opts_group.html#gacb7e964ae54b74d972d72e118b7b8bdf"title="Set the list of servers to try to (re)connect to.">natsOptions_SetServers</a> or <aclass="el"href="group__conn_mgt_group.html#gafb83c8d7970ba68be0e6c40c38cdfde4"title="Connects to a NATS Server using any of the URL from the given list.">natsConnection_ConnectTo</a>. The client library would connect (or reconnect) only to this given list of URLs, so if any of the server in the list required authentication, you were responsible for providing the appropriate token in the URLs.<br/>
<br/>
However, with cluster auto-discovery, the client library asynchronously receives URLs of servers in the cluster. These URLs do not contain any embedded tokens. <br/>
You need to use this function (or <aclass="el"href="group__opts_group.html#ga5b99da7dd74aac3be962f323c3863d9e"title="Sets the user name/password to use when not specified in the URL.">natsOptions_SetUserInfo</a>) to instruct the client library to use this token when connecting to a server that requires authentication and for which there is no embedded token in the URL.</p>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="group__opts_group.html#ga5b99da7dd74aac3be962f323c3863d9e"title="Sets the user name/password to use when not specified in the URL.">natsOptions_SetUserInfo</a></dd>
<dd>
<aclass="el"href="group__opts_group.html#ga3f7e760214417c7d87541ecb9ab5bea5"title="Sets the URL to connect to.">natsOptions_SetURL</a></dd>
<dd>
<aclass="el"href="group__opts_group.html#gacb7e964ae54b74d972d72e118b7b8bdf"title="Set the list of servers to try to (re)connect to.">natsOptions_SetServers</a></dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">token</td><td>the token to send to the server during connect. </td></tr>
<p>For use cases where setting a static token through the URL<br/>
or through <aclass="el"href="group__opts_group.html#gad58a5b9dabadeebda30e952ff7b39193"title="Sets the token to use when not specified in the URL.">natsOptions_SetToken</a> is not desirable.<br/>
<br/>
This function can be used to generate a token whenever the client needs one.<br/>
Some example of use cases: expiring token, credential rotation, ...</p>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="group__opts_group.html#gad58a5b9dabadeebda30e952ff7b39193"title="Sets the token to use when not specified in the URL.">natsOptions_SetToken</a></dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">tokenCb</td><td>the tokenCb to use to generate a token to the server during connect. </td></tr>
<tr><tdclass="paramname">closure</td><td>a pointer to an user defined object (can be <code>NULL</code>). See the <aclass="el"href="group__callbacks_group.html#gad1a5ac566893e13dc8c81ac0e9c87afe"title="Callback used to deliver messages to the application.">natsMsgHandler</a> prototype. </td></tr>
<p>If 'noRandomize' is true, then the list of server URLs is used in the order provided by <aclass="el"href="group__opts_group.html#ga3f7e760214417c7d87541ecb9ab5bea5"title="Sets the URL to connect to.">natsOptions_SetURL()</a> + <aclass="el"href="group__opts_group.html#gacb7e964ae54b74d972d72e118b7b8bdf"title="Set the list of servers to try to (re)connect to.">natsOptions_SetServers()</a>. Otherwise, the list is formed in a random order.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">noRandomize</td><td>if <code>true</code>, the list will be used as-is. </td></tr>
<p>This timeout, expressed in milliseconds, is used to interrupt a (re)connect attempt to a <code>NATS Server</code>. This timeout is used both for the low level TCP connect call, and for timing out the response from the server to the client's initial <code>PING</code> protocol.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">timeout</td><td>the time, in milliseconds, allowed for an individual connect (or reconnect) to complete. </td></tr>
<p>This name is sent as part of the <code>CONNECT</code> protocol. There is no default name.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">name</td><td>the name to set. </td></tr>
<p>Indicates to the server if the client wants a secure (SSL/TLS) connection.</p>
<p>The default is <code>false</code>.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">secure</td><td><code>true</code> for a secure connection, <code>false</code> otherwise. </td></tr>
<p>Loads the trusted CA certificates from a file.</p>
<p>Note that the certificates are added to a SSL context for this <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object at the time of this call, so possible errors while loading the certificates will be reported now instead of when a connection is created. You can get extra information by calling <aclass="el"href="group__library_group.html#gadecfd49a58b581dbba40da77b195fd85"title="Returns the calling thread's last known error.">nats_GetLastError</a>.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">fileName</td><td>the file containing the CA certificates. </td></tr>
<p>Similar to <aclass="el"href="group__opts_group.html#ga2cd6563694a439b3949a31fd81103099"title="Loads the trusted CA certificates from a file.">natsOptions_LoadCATrustedCertificates</a> expect that instead of loading from file, this loads from the given memory location.</p>
<p>If more than one certificate need to be provided, they need to be concatenated. For instance:</p>
</div><!-- fragment --><dlclass="section see"><dt>See also</dt><dd><aclass="el"href="group__opts_group.html#ga2cd6563694a439b3949a31fd81103099"title="Loads the trusted CA certificates from a file.">natsOptions_LoadCATrustedCertificates</a></dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">certificates</td><td>the string containing the concatenated CA certificates. </td></tr>
<p>The certificates must be in PEM format and must be sorted starting with the subject's certificate, followed by intermediate CA certificates if applicable, and ending at the highest level (root) CA.</p>
<p>The private key file format supported is also PEM.</p>
<p>See <aclass="el"href="group__opts_group.html#ga2cd6563694a439b3949a31fd81103099"title="Loads the trusted CA certificates from a file.">natsOptions_LoadCATrustedCertificates</a> regarding error reports.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">certsFileName</td><td>the file containing the client certificates. </td></tr>
<tr><tdclass="paramname">keyFileName</td><td>the file containing the client private key. </td></tr>
<p>Similar to <aclass="el"href="group__opts_group.html#ga36943e2ba53d05407cdabc4e7e96484b"title="Loads the certificate chain from a file, using the given key.">natsOptions_LoadCertificatesChain</a> expect that instead of loading from file, this loads from the given memory locations.</p>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="group__opts_group.html#ga36943e2ba53d05407cdabc4e7e96484b"title="Loads the certificate chain from a file, using the given key.">natsOptions_LoadCertificatesChain()</a></dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">cert</td><td>the memory location containing the client certificates. </td></tr>
<tr><tdclass="paramname">key</td><td>the memory location containing the client private key. </td></tr>
<dlclass="section note"><dt>Note</dt><dd>This function does not impact TLSv1.3 ciphersuites.</dd></dl>
<p>Sets the list of available ciphers. Check <ahref="https://www.openssl.org/docs/man1.1.1/man1/ciphers.html">https://www.openssl.org/docs/man1.1.1/man1/ciphers.html</a> for the proper syntax. Here is an example:</p>
<blockquoteclass="doxtable">
<p>‍"-ALL:HIGH" </p>
</blockquote>
<p>See <aclass="el"href="group__opts_group.html#ga2cd6563694a439b3949a31fd81103099"title="Loads the trusted CA certificates from a file.">natsOptions_LoadCATrustedCertificates</a> regarding error reports.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<p>Sets the list of available ciphers. Check <ahref="https://www.openssl.org/docs/man1.1.1/man3/SSL_CTX_set_ciphersuites.html">https://www.openssl.org/docs/man1.1.1/man3/SSL_CTX_set_ciphersuites.html</a> for the proper syntax. Here is an example:</p>
<p>See <aclass="el"href="group__opts_group.html#ga2cd6563694a439b3949a31fd81103099"title="Loads the trusted CA certificates from a file.">natsOptions_LoadCATrustedCertificates</a> regarding error reports.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<p>If set, the library will check that the hostname in the server certificate matches the given <code>hostname</code>. This will occur when a connection is created, not at the time of this call.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">hostname</td><td>the expected server certificate hostname. </td></tr>
<p>By default, the server certificate is verified. You can disable the verification by passing <code>true</code> to this function.</p>
<dlclass="section warning"><dt>Warning</dt><dd>This is fine for tests but use with caution since this is not secure.</dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">skip</td><td>set it to <code>true</code> to disable - or skip - server certificate verification. </td></tr>
<p>Sets the verbose mode. If <code>true</code>, sends are echoed by the server with an <code>OK</code> protocol message.</p>
<p>The default is <code>false</code>.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">verbose</td><td><code>true</code> for a verbose protocol, <code>false</code> otherwise. </td></tr>
<p>Sets the pedantic mode. If <code>true</code> some extra checks will be performed by the server.</p>
<p>The default is <code>false</code></p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">pedantic</td><td><code>true</code> for a pedantic protocol, <code>false</code> otherwise. </td></tr>
<p>Interval, expressed in milliseconds, in which the client sends <code>PING</code> protocols to the <code>NATS Server</code>.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">interval</td><td>the interval, in milliseconds, at which the connection will send <code>PING</code> protocols to the server. </td></tr>
<p>Specifies the maximum number of <code>PING</code>s without corresponding <code>PONG</code>s (which should be received from the server) before closing the connection with the <aclass="el"href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80aa76d5e3ce051bc7510be90e73663c93d">NATS_STALE_CONNECTION</a> status. If reconnection is allowed, the client library will try to reconnect.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">maxPingsOut</td><td>the maximum number of <code>PING</code>s without <code>PONG</code>s (positive number). </td></tr>
<p>Sets the size, in bytes, of the internal read/write buffers used for reading/writing data from a socket. If not specified, or the value is 0, the library will use a default value, currently set to 32KB.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">ioBufSize</td><td>the size, in bytes, of the internal buffer for read/write operations. </td></tr>
<p>Specifies whether or not the client library should try to reconnect when losing the connection to the <code>NATS Server</code>.</p>
<p>The default is <code>true</code>.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">allow</td><td><code>true</code> if the connection is allowed to reconnect, <code>false</code> otherwise. </td></tr>
<p>Specifies the maximum number of reconnect attempts.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">maxReconnect</td><td>the maximum number of reconnects (positive number). </td></tr>
<p>Specifies how long to wait between two reconnect attempts from the same server. This means that if you have a list with S1,S2 and are currently connected to S1, and get disconnected, the library will immediately attempt to connect to S2. If this fails, it will go back to S1, and this time will wait for <code>reconnectWait</code> milliseconds since the last attempt to connect to S1.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">reconnectWait</td><td>the time, in milliseconds, to wait between attempts to reconnect to the same server. </td></tr>
<p>After a disconnect, the library will try to reconnect to any server URLs in its list (the URLs are either provided by the user or discovered through gossip protocol).</p>
<p>After the library failed to reconnect to every server in the list, it will wait for <code>reconnectWait</code> as specified with <aclass="el"href="group__opts_group.html#ga2730f4e16e318a2ef8de98dbf6ede807"title="Sets the time between reconnect attempts.">natsOptions_SetReconnectWait()</a>. This option adds some random jitter to the reconnect wait delay.</p>
<p>This will help minimize the thundering herd phenomenon. For instance, suppose a server has 1000 connections, all were created at different times, but have the same reconnect wait option. If this server suddenly stops, then all connections will detect the failure and initiate a reconnect at the same time. The issue is even greater when those connections are TLS because of the added cost of the TLS handshake.</p>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="group__opts_group.html#ga2730f4e16e318a2ef8de98dbf6ede807"title="Sets the time between reconnect attempts.">natsOptions_SetReconnectWait()</a></dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">jitter</td><td>the jitter in milliseconds for non TLS connections. </td></tr>
<tr><tdclass="paramname">jitterTLS</td><td>the jitter in milliseconds for TLS connections. </td></tr>
<p>This callback is invoked after the library tried every URL in the server list and failed to reconnect. It passes to the user the current number of attempts. This function shall return the amount of time the library will sleep before attempting to reconnect again.</p>
<p>It is strongly recommended that this value contains some jitter to prevent all connections to attempt reconnecting at the same time.</p>
<dlclass="section note"><dt>Note</dt><dd>When using this approach, the reconnect wait as specified by <aclass="el"href="group__opts_group.html#ga2730f4e16e318a2ef8de98dbf6ede807"title="Sets the time between reconnect attempts.">natsOptions_SetReconnectWait()</a> is ignored.</dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">cb</td><td>the custom reconnect delay handler to invoke. </td></tr>
<tr><tdclass="paramname">closure</td><td>a pointer to an user defined object (can be <code>NULL</code>). See the <aclass="el"href="group__callbacks_group.html#ga3353d4b92851c52121f65aaf0684cba4"title="Callback used to specify how long to wait between reconnects.">natsCustomReconnectDelayHandler</a> prototype. </td></tr>
<p>Sets the size, in bytes, of the backing buffer holding published data while the library is reconnecting. Once this buffer has been exhausted, publish operations will return the <aclass="el"href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80a317fb9be1a80f6b1877f96a9a2db16ad"title="A buffer is not large enough to accommodate the data.">NATS_INSUFFICIENT_BUFFER</a> error. If not specified, or the value is 0, the library will use a default value, currently set to 8MB.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">reconnectBufSize</td><td>the size, in bytes, of the backing buffer for write operations during a reconnect. </td></tr>
<p>Specifies the maximum number of inbound messages that can be buffered in the library, for each subscription, before inbound messages are dropped and <aclass="el"href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80ae93ff5b7fe31f8570308385d92d317b0">NATS_SLOW_CONSUMER</a> status is reported to the <aclass="el"href="group__callbacks_group.html#ga9e511dffa471dfb971b7dd2b12329626"title="Callback used to notify the user of errors encountered while processing inbound messages.">natsErrHandler</a> callback (if one has been set).</p>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="group__opts_group.html#ga127ec7a8196b453947a7fa9a64096cbd"title="Sets the error handler for asynchronous events.">natsOptions_SetErrorHandler()</a></dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">maxPending</td><td>the number of messages allowed to be buffered by the library before triggering a slow consumer scenario. </td></tr>
<p>Specifies the callback to invoke when an asynchronous error occurs. This is used by applications having only asynchronous subscriptions that would not know otherwise that a problem with the connection occurred.</p>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="group__callbacks_group.html#ga9e511dffa471dfb971b7dd2b12329626"title="Callback used to notify the user of errors encountered while processing inbound messages.">natsErrHandler</a></dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">closure</td><td>a pointer to an user object that will be passed to the callback. <code>closure</code> can be <code>NULL</code>. </td></tr>
<p>Specifies the callback to invoke when a connection is terminally closed, that is, after all reconnect attempts have failed (when reconnection is allowed).</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">closedCb</td><td>the callback to be invoked when the connection is closed. </td></tr>
<tr><tdclass="paramname">closure</td><td>a pointer to an user object that will be passed to the callback. <code>closure</code> can be <code>NULL</code>. </td></tr>
<p>Specifies the callback to invoke when a connection to the <code>NATS Server</code> is lost.</p>
<dlclass="section warning"><dt>Warning</dt><dd>Invocation of this callback is asynchronous, which means that the state of the connection may have changed when this callback is invoked.</dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">disconnectedCb</td><td>the callback to be invoked when a connection to a server is lost </td></tr>
<tr><tdclass="paramname">closure</td><td>a pointer to an user object that will be passed to the callback. <code>closure</code> can be <code>NULL</code>. </td></tr>
<p>Specifies the callback to invoke when the client library has successfully reconnected to a <code>NATS Server</code>.</p>
<dlclass="section warning"><dt>Warning</dt><dd>Invocation of this callback is asynchronous, which means that the state of the connection may have changed when this callback is invoked.</dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">reconnectedCb</td><td>the callback to be invoked when the connection to a server has been re-established. </td></tr>
<tr><tdclass="paramname">closure</td><td>a pointer to an user object that will be passed to the callback. <code>closure</code> can be <code>NULL</code>. </td></tr>
<p>Specifies the callback to invoke when the client library has been notified of one or more new <code>NATS Servers</code>.</p>
<dlclass="section warning"><dt>Warning</dt><dd>Invocation of this callback is asynchronous, which means that the state may have changed when this callback is invoked.</dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">discoveredServersCb</td><td>the callback to be invoked when new servers have been discovered. </td></tr>
<tr><tdclass="paramname">closure</td><td>a pointer to an user object that will be passed to the callback. <code>closure</code> can be <code>NULL</code>. </td></tr>
<p>By default, when a server joins a cluster, a client is notified of the new URL and added to the list so it can be used in case of a reconnect.</p>
<p>The servers can be configured to disable this gossip, however, if not done at the servers level, this option allows the discovered servers to be ignored.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">ignore</td><td>if discovered server should be ignored or not. </td></tr>
<p>Specifies the callback to invoke when the server notifies the connection that it entered lame duck mode, that is, going to gradually disconnect all its connections before shuting down. This is often used in deployments when upgrading NATS Servers.</p>
<dlclass="section warning"><dt>Warning</dt><dd>Invocation of this callback is asynchronous, which means that the state may have changed when this callback is invoked.</dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">lameDuckCb</td><td>the callback to be invoked when server enters lame duck mode. </td></tr>
<tr><tdclass="paramname">closure</td><td>a pointer to an user object that will be passed to the callback. <code>closure</code> can be <code>NULL</code>. </td></tr>
<p>If you want to use an external event loop, the <code>NATS</code> library will not create a thread to read data from the socket, and will not directly write data to the socket. Instead, the library will invoke those callbacks for various events.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">loop</td><td>the <code>void*</code> pointer to the external event loop. </td></tr>
<tr><tdclass="paramname">attachCb</td><td>the callback invoked after the connection is connected, or reconnected. </td></tr>
<tr><tdclass="paramname">readCb</td><td>the callback invoked when the event library should start or stop polling for read events. </td></tr>
<tr><tdclass="paramname">writeCb</td><td>the callback invoked when the event library should start or stop polling for write events. </td></tr>
<tr><tdclass="paramname">detachCb</td><td>the callback invoked when a connection is closed. </td></tr>
<p>Normally, each asynchronous subscriber that is created has its own message delivery thread. The advantage is that it reduces lock contentions, therefore improving performance.<br/>
However, if an application creates many subscribers, this is not scaling well since the process would use too many threads.</p>
<p>When a connection is created from a <code>nats_Options</code> that has enabled global message delivery, asynchronous subscribers from this connection will use a shared thread pool responsible for message delivery.</p>
<dlclass="section note"><dt>Note</dt><dd>The message order per subscription is still guaranteed.</dd></dl>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="group__library_group.html#gab21e94ce7a7d226611ea2c05914cf19d"title="Sets the maximum size of the global message delivery thread pool.">nats_SetMessageDeliveryPoolSize()</a></dd>
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">global</td><td>if <code>true</code>, uses the global message delivery thread pool, otherwise, each asynchronous subscriber will create their own message delivery thread. </td></tr>
<tdclass="markdownTableBodyNone">46 </td><tdclass="markdownTableBodyNone">try IPv4 first, if it fails try IPv6 </td></tr>
<trclass="markdownTableRowEven">
<tdclass="markdownTableBodyNone">64 </td><tdclass="markdownTableBodyNone">try IPv6 first, if it fails try IPv4 </td></tr>
<trclass="markdownTableRowOdd">
<tdclass="markdownTableBodyNone">4 </td><tdclass="markdownTableBodyNone">use only IPv4 </td></tr>
<trclass="markdownTableRowEven">
<tdclass="markdownTableBodyNone">6 </td><tdclass="markdownTableBodyNone">use only IPv6 </td></tr>
<trclass="markdownTableRowOdd">
<tdclass="markdownTableBodyNone">0 </td><tdclass="markdownTableBodyNone">any family, no specific order </td></tr>
</table>
<dlclass="section note"><dt>Note</dt><dd>If this option is not set, or you specify <code>0</code> for the order, the library will use the first IP (based on the DNS configuration) for which a successful connection can be made.</dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">order</td><td>a string representing the order for the IP resolution. </td></tr>
<p>For throughput performance, the client library tries by default to buffer as much data as possible before sending it over TCP.</p>
<p>Setting this option to <code>true</code> will make Publish calls send the data right away, reducing latency, but also throughput.</p>
<p>A good use-case would be a connection used to solely send replies. Imagine, a requestor sending a request, waiting for the reply before sending the next request.<br/>
The replier application will send only one reply at a time (since it will not receive the next request until the requestor receives the reply).<br/>
In such case, it makes sense for the reply to be sent right away.</p>
<p>The alternative would be to call <aclass="el"href="group__conn_mgt_group.html#ga1c98f8d89bb8e20ea8621e860a90267f"title="Flushes the connection.">natsConnection_Flush()</a>, but this call requires a round-trip with the server, which is less efficient than using this option.</p>
<p>Note that the Request() call already automatically sends the request as fast as possible, there is no need to set an option for that.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">sendAsap</td><td>a boolean indicating if published data should be sent right away or be buffered. </td></tr>
<p>Setting <code>useOldStyle</code> to <code>true</code> forces the request calls to use the original behavior, which is to create a new inbox, a new subscription on that inbox and set auto-unsubscribe to 1.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">useOldStyle</td><td>a boolean indicating if old request style should be used. </td></tr>
<p>If this option is enabled, all pending <aclass="el"href="group__conn_pub_group.html#gaf4b4a022f9c21fc269b87c000330c5a7"title="Sends a request and waits for a reply.">natsConnection_Request()</a> family calls will fail with the <aclass="el"href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80abef517217119e8446a8e3382e1f37eb3">NATS_CONNECTION_DISCONNECTED</a> status.</p>
<dlclass="section note"><dt>Note</dt><dd>This does not apply to requests from connections that use the old style requests.</dd></dl>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="group__opts_group.html#ga70aa85319933d78c0076cc862fa3e5a6"title="Switches the use of old style requests.">natsOptions_UseOldRequestStyle</a></dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">failRequests</td><td>a boolean indicating if pending requests should fail when a disconnect event occurs. </td></tr>
<p>This configures whether the server will echo back messages that are sent on this connection if there is also matching subscriptions.</p>
<p>Set this to <code>true</code> to prevent the server from sending back messages produced by this connection. The default is false, that is, messages originating from this connection will be sent by the server if the connection has matching subscriptions.</p>
<dlclass="section note"><dt>Note</dt><dd>This is supported on servers >= version 1.2.0. Calling <aclass="el"href="group__conn_mgt_group.html#ga740be1ba16a8570eb98ef6755ebf52ce"title="Connects to a NATS Server using the provided options.">natsConnection_Connect()</a> with the option set to <code>true</code> to server below this version will return the <code>NATS_NO_SERVER_SUPPORT</code> error.</dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">noEcho</td><td>a boolean indicating if sent messages can be delivered back to this connection or not. </td></tr>
<p>By default, <aclass="el"href="group__conn_mgt_group.html#ga740be1ba16a8570eb98ef6755ebf52ce"title="Connects to a NATS Server using the provided options.">natsConnection_Connect()</a> attempts to connect to a server specified in provided list of servers. If it cannot connect and the list has been fully tried, the function returns an error.</p>
<p>This option is used to changed this default behavior.</p>
<p>If <code>retry</code> is set to <code>true</code> and connection cannot be established right away, the library will attempt to connect based on the reconnect attempts and delay settings.</p>
<dlclass="section note"><dt>Note</dt><dd>The connect retry logic uses reconnect settings even if <aclass="el"href="group__opts_group.html#ga3d1d3cb2f2a0e23d27dd60e96d1cc91b"title="Indicates if the connection will be allowed to reconnect.">natsOptions_SetAllowReconnect()</a> has been set to false. In other words, a failed connect may be retried even though a reconnect will not be allowed should the connection to the server be lost after initial connect.</dd></dl>
<p>The behavior will then depend on the value of the <code>connectedCb</code> parameter:</p>
<ul>
<li>If <code>NULL</code>, then the call blocks until it can connect or exhausts the reconnect attempts.</li>
<li>If not <code>NULL</code>, and no connection can be immediately established, the <aclass="el"href="group__conn_mgt_group.html#ga740be1ba16a8570eb98ef6755ebf52ce"title="Connects to a NATS Server using the provided options.">natsConnection_Connect()</a> calls returns <aclass="el"href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80a49a1ea653ce112b3c53eedebcd60811d">NATS_NOT_YET_CONNECTED</a> to indicate that no connection is currently established, but will try asynchronously to connect using the reconnect attempts/delay settings. If the connection is later established, the specified callback will be invoked. If no connection can be made and the retry attempts are exhausted, the callback registered with <aclass="el"href="group__opts_group.html#ga44410242e73134e5bb51ef27904a9253"title="Sets the callback to be invoked when a connection to a server is permanently lost.">natsOptions_SetClosedCB()</a>, if any, will be invoked.</li>
</ul>
<dlclass="section note"><dt>Note</dt><dd>If <aclass="el"href="group__conn_mgt_group.html#ga740be1ba16a8570eb98ef6755ebf52ce"title="Connects to a NATS Server using the provided options.">natsConnection_Connect()</a> returns <code>NATS_OK</code> (that is, a connection to a <code>NATS Server</code> was established in that call), then the <code>connectedCb</code> callback will not be invoked.</dd></dl>
<p>If <code>retry</code> is set to false, <aclass="el"href="group__conn_mgt_group.html#ga740be1ba16a8570eb98ef6755ebf52ce"title="Connects to a NATS Server using the provided options.">natsConnection_Connect()</a> behaves as originally designed, that is, returns an error and no connection object if failing to connect to any server in the list.</p>
<dlclass="section note"><dt>Note</dt><dd>The <code>connectedCb</code> parameter is ignored and set to <code>NULL</code> in the options object when <code>retry</code> is set to <code>false</code>.</dd></dl>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="group__opts_group.html#gab54cd2719c0b64eebd6c7b83dd2908a0"title="Sets the maximum number of reconnect attempts.">natsOptions_SetMaxReconnect()</a></dd>
<dd>
<aclass="el"href="group__opts_group.html#ga2730f4e16e318a2ef8de98dbf6ede807"title="Sets the time between reconnect attempts.">natsOptions_SetReconnectWait()</a></dd>
<dd>
<aclass="el"href="group__opts_group.html#ga44410242e73134e5bb51ef27904a9253"title="Sets the callback to be invoked when a connection to a server is permanently lost.">natsOptions_SetClosedCB()</a></dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">retry</td><td>a boolean indicating if a failed connect should be retried. </td></tr>
<tr><tdclass="paramname">connectedCb</td><td>if <code>retry</code> is true and this is not <code>NULL</code>, then the connect may be asynchronous and this callback will be invoked if the connect succeeds. </td></tr>
<tr><tdclass="paramname">closure</td><td>a pointer to an user object that will be passed to the callback. <code>closure</code> can be <code>NULL</code>. </td></tr>
<p>Any time the library creates a TCP connection to the server, the server in response sends an <code>INFO</code> protocol. That <code>INFO</code> protocol, for NATS Server at v2.0.0+, may include a <code>nonce</code> for the client to sign.</p>
<p>If this option is set, the library will invoke the two handlers to fetch the user JWT and sign the server's nonce.</p>
<p>This is an option that will be used only by users that are able to sign using Ed25519 (public-key signature system). Most users will probably prefer the user of <aclass="el"href="group__opts_group.html#ga59b47f7b7a19085cf8eaada9bfe5606e"title="Sets the file(s) to use to fetch user JWT and seed required to sign nonce.">natsOptions_SetUserCredentialsFromFiles()</a>.</p>
<dlclass="section note"><dt>Note</dt><dd><aclass="el"href="group__opts_group.html#ga60117450fc1f7b6f81bab455aeed7515"title="Sets the callbacks to fetch user JWT and sign server's nonce.">natsOptions_SetUserCredentialsCallbacks()</a> and <aclass="el"href="group__opts_group.html#ga0290eac4665569c850468d9f00e246a0"title="Sets the NKey public key and signature callback.">natsOptions_SetNKey()</a> are mutually exclusive. Calling this function will remove the NKey and replace the signature handler, that was set with <aclass="el"href="group__opts_group.html#ga0290eac4665569c850468d9f00e246a0"title="Sets the NKey public key and signature callback.">natsOptions_SetNKey()</a>, with this one.</dd></dl>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="group__callbacks_group.html#ga258b30458134be90f17315c037f34b7b"title="Callback used to fetch and return account signed user JWT.">natsUserJWTHandler</a></dd>
<dd>
<aclass="el"href="group__callbacks_group.html#gab786ffd670c86de0563559351305080b"title="Callback used to sign a nonce sent by the server.">natsSignatureHandler</a></dd>
<dd>
<aclass="el"href="group__opts_group.html#ga59b47f7b7a19085cf8eaada9bfe5606e"title="Sets the file(s) to use to fetch user JWT and seed required to sign nonce.">natsOptions_SetUserCredentialsFromFiles()</a></dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">ujwtCB</td><td>the callback to invoke to fetch the user JWT. </td></tr>
<tr><tdclass="paramname">ujwtClosure</td><td>the closure that will be passed to the <code>ujwtCB</code> callback. </td></tr>
<tr><tdclass="paramname">sigCB</td><td>the callback to invoke to sign the server nonce. </td></tr>
<tr><tdclass="paramname">sigClosure</td><td>the closure that will be passed to the <code>sigCB</code> callback. </td></tr>
<p>This is a convenient option that specifies the files(s) to use to fetch the user JWT and the user seed to be used to sign the server's nonce.</p>
<p>The <code>userOrChainedFile</code> contains the user JWT token and possibly the user NKey seed. Note the format of this file:</p>
<divclass="fragment"><divclass="line">-----BEGIN NATS USER JWT-----</div>
<divclass="line">...an user JWT token...</div>
<divclass="line">------END NATS USER JWT------</div>
<divclass="line"></div>
<divclass="line">************************* IMPORTANT *************************</div>
<divclass="line">NKEY Seed printed below can be used to sign and prove identity.</div>
<divclass="line">NKEYs are sensitive and should be treated as secrets.</div>
<divclass="line"></div>
<divclass="line">-----BEGIN USER NKEY SEED-----</div>
<divclass="line">SU...</div>
<divclass="line">------END USER NKEY SEED------</div>
</div><!-- fragment --><p>The <code>---BEGIN NATS USER JWT---</code> header is used to detect where the user JWT is in this file.</p>
<p>If the file does not contain the user NKey seed, then the <code>seedFile</code> file name must be specified and must contain the user NKey seed.</p>
<dlclass="section note"><dt>Note</dt><dd><aclass="el"href="group__opts_group.html#ga59b47f7b7a19085cf8eaada9bfe5606e"title="Sets the file(s) to use to fetch user JWT and seed required to sign nonce.">natsOptions_SetUserCredentialsFromFiles()</a> and <aclass="el"href="group__opts_group.html#ga0290eac4665569c850468d9f00e246a0"title="Sets the NKey public key and signature callback.">natsOptions_SetNKey()</a> are mutually exclusive. Calling this function will remove the NKey and replace the signature handler, that was set with <aclass="el"href="group__opts_group.html#ga0290eac4665569c850468d9f00e246a0"title="Sets the NKey public key and signature callback.">natsOptions_SetNKey()</a>, with an internal one that will handle the signature.</dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">userOrChainedFile</td><td>the name of the file containing the user JWT and possibly the user NKey seed. </td></tr>
<tr><tdclass="paramname">seedFile</td><td>the name of the file containing the user NKey seed. </td></tr>
<p>This function acts similarly to <aclass="el"href="group__opts_group.html#ga59b47f7b7a19085cf8eaada9bfe5606e"title="Sets the file(s) to use to fetch user JWT and seed required to sign nonce.">natsOptions_SetUserCredentialsFromFiles()</a> but reads from memory instead from a file. Also it assumes that <code>jwtAndSeedContent</code> contains both the JWT and NKey seed.</p>
<p>As for the format, see <aclass="el"href="group__opts_group.html#ga59b47f7b7a19085cf8eaada9bfe5606e"title="Sets the file(s) to use to fetch user JWT and seed required to sign nonce.">natsOptions_SetUserCredentialsFromFiles()</a> documentation.</p>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="group__opts_group.html#ga59b47f7b7a19085cf8eaada9bfe5606e"title="Sets the file(s) to use to fetch user JWT and seed required to sign nonce.">natsOptions_SetUserCredentialsFromFiles()</a></dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">jwtAndSeedContent</td><td>string containing user JWT and user NKey seed. </td></tr>
<p>Any time the library creates a TCP connection to the server, the server in response sends an <code>INFO</code> protocol. That <code>INFO</code> protocol, for NATS Server at v2.0.0+, may include a <code>nonce</code> for the client to sign.</p>
<p>If this option is set, the library will add the NKey public key <code>pubKey</code> to the <code>CONNECT</code> protocol along with the server's nonce signature resulting from the invocation of the signature handler <code>sigCB</code>.</p>
<dlclass="section note"><dt>Note</dt><dd><aclass="el"href="group__opts_group.html#ga0290eac4665569c850468d9f00e246a0"title="Sets the NKey public key and signature callback.">natsOptions_SetNKey()</a> and <aclass="el"href="group__opts_group.html#ga60117450fc1f7b6f81bab455aeed7515"title="Sets the callbacks to fetch user JWT and sign server's nonce.">natsOptions_SetUserCredentialsCallbacks()</a> or <aclass="el"href="group__opts_group.html#ga59b47f7b7a19085cf8eaada9bfe5606e"title="Sets the file(s) to use to fetch user JWT and seed required to sign nonce.">natsOptions_SetUserCredentialsFromFiles()</a> are mutually exclusive. Calling this function will remove the user JWT callback and replace the signature handler, that was set with one of the user credentials options, with this one.</dd></dl>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="group__callbacks_group.html#gab786ffd670c86de0563559351305080b"title="Callback used to sign a nonce sent by the server.">natsSignatureHandler</a></dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">pubKey</td><td>the user NKey public key. </td></tr>
<tr><tdclass="paramname">sigCB</td><td>the callback to invoke to sign the server nonce. </td></tr>
<tr><tdclass="paramname">sigClosure</td><td>the closure that will be passed to the <code>sigCB</code> callback. </td></tr>
<p>Any time the library creates a TCP connection to the server, the server in response sends an <code>INFO</code> protocol. That <code>INFO</code> protocol, for NATS Server at v2.0.0+, may include a <code>nonce</code> for the client to sign.</p>
<p>If this option is set, the library will add the NKey public key <code>pubKey</code> to the <code>CONNECT</code> protocol along with the server's nonce signature signed using the private key from the provided seed file. The library takes care of clearing the memory holding the private key read from the file as soon as it is no longer needed.</p>
<dlclass="section note"><dt>Note</dt><dd><aclass="el"href="group__opts_group.html#ga696f02e0493c00d3c1eafff45b62b68e"title="Sets the NKey public key and its seed file.">natsOptions_SetNKeyFromSeed()</a> and <aclass="el"href="group__opts_group.html#ga60117450fc1f7b6f81bab455aeed7515"title="Sets the callbacks to fetch user JWT and sign server's nonce.">natsOptions_SetUserCredentialsCallbacks()</a> or <aclass="el"href="group__opts_group.html#ga59b47f7b7a19085cf8eaada9bfe5606e"title="Sets the file(s) to use to fetch user JWT and seed required to sign nonce.">natsOptions_SetUserCredentialsFromFiles()</a> are mutually exclusive. Calling this function will remove the user JWT callback and replace the signature handler, that was set with one of the user credentials options, with this one.</dd></dl>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="group__callbacks_group.html#gab786ffd670c86de0563559351305080b"title="Callback used to sign a nonce sent by the server.">natsSignatureHandler</a></dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">pubKey</td><td>the user NKey public key. </td></tr>
<tr><tdclass="paramname">seedFile</td><td>the name of the file containing the user NKey seed. </td></tr>
<p>If this is set, the socket is set to non-blocking mode and write will have a deadline set. If the deadline is reached, the write call will return an error which will translate to publish calls, or any library call trying to send data to the server, to possibly fail.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">deadline</td><td>the write deadline expressed in milliseconds. If set to 0, it means that there is no deadline and socket is in blocking mode. </td></tr>
<p>By default, when a connection to a NATS Server v2.2.0+ is made, the library signals to the server that it supports the "no responders" feature, which means that if a request is made, and there are no subscriptions on the request subject (no responders), then the server sends back an empty message with the header "Status" and value "503". The request APIs capture this message and instead return a <aclass="el"href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80aab97324e40ccfe1360080c651c330e62"title="No responders were running when the server received the request.">NATS_NO_RESPONDERS</a> status, instead of waiting for the timeout to occur and return <aclass="el"href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80ab88994c9ea9889ac4d9d656d62f550ed">NATS_TIMEOUT</a>.</p>
<p>In case where users set up their own asynchronous subscription on the reply subject and publish the request with <aclass="el"href="group__conn_pub_group.html#gaaaa3d75ffec2dcdc6bf905cdb1eee59e"title="Publishes data on a subject expecting replies on the given reply.">natsConnection_PublishRequest</a> and the like, then the message callback may be invoked with this "no responders" message, which can be checked with <aclass="el"href="group__msg_group.html#ga43aa4a8e4b93725b4876ee2677e19c7b"title="Indicates if this message is a "no responders" message from the server.">natsMsg_IsNoResponders</a>.</p>
<p>However, if users don't want to have to deal with that, it is possible to instruct the server to disable this feature for a given connection. If that is the case, requests will behave as with pre-v2.2.0 servers, in that the request will timeout when there are no responders.</p>
<dlclass="section note"><dt>Note</dt><dd>This function is to disable the feature that is normally enabled by default. Passing <code>false</code> means that it would enable it again if you had previously disable the option. However, the feature may still be disabled when connecting to a server that does not support it.</dd></dl>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="group__msg_group.html#ga43aa4a8e4b93725b4876ee2677e19c7b"title="Indicates if this message is a "no responders" message from the server.">natsMsg_IsNoResponders()</a></dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<tr><tdclass="paramname">disabled</td><td>the boolean to indicate if the feature should be disabled or not. </td></tr>
<p>The default inbox prefix is "_INBOX", but you can change it using this option. This can be useful when setting permissions and/or with import/exports across different accounts.</p>
<p>The prefix must be a valid subject and not contain any of the wildcards tokens <code>*</code> nor <code>></code>.</p>
<p>To clear the custom inbox prefix, call this function with <code>NULL</code> or the empty string.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<p>By default library allocates natsMsg with payload buffer size equal to payload size. Sometimes it can be useful to add some padding to the end of the buffer which can be tweaked using this option.</p>
<p>To clear the custom message buffer padding, call this function with 0. Changing this option has no effect on existing NATS connections.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object. </td></tr>
<p>Destroys the natsOptions object, freeing used memory. See the note in the <aclass="el"href="group__opts_group.html#ga61d4a0cf2fbf7d13cc910e5a00c575be"title="Creates a natsOptions object.">natsOptions_Create()</a> call.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">opts</td><td>the pointer to the <aclass="el"href="group__types_group.html#gabcc48b40a81fe302188f4ee06ea9c54e"title="Way to configure a natsConnection.">natsOptions</a> object to destroy. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- HTML footer for doxygen 1.8.10-->
<!-- start footer part -->
<divid="nav-path"class="navpath"><!-- id is needed for treeview function! -->
<ul>
<liclass="footer">NATS.IO Supported By Synadia Communications Inc.