<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Client on Grafana Labs</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-net-grpc/client/</link><description>Recent content in Client on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/k6/v2.3.x/javascript-api/k6-net-grpc/client/index.xml" rel="self" type="application/rss+xml"/><item><title>Client.load(importPaths, ...protoFiles)</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-net-grpc/client/client-load/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-net-grpc/client/client-load/</guid><content><![CDATA[&lt;h1 id=&#34;clientloadimportpaths-protofiles&#34;&gt;Client.load(importPaths, &amp;hellip;protoFiles)&lt;/h1&gt;
&lt;p&gt;Loads and parses the protocol buffer descriptors so they are available to the client to marshal/unmarshal the correct request and response data structures for the RPC schema.&lt;/p&gt;
&lt;p&gt;Must be called within the 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/test-lifecycle/&#34;&gt;&lt;code&gt;init&lt;/code&gt; phase&lt;/a&gt;.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Parameter&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;importPaths&lt;/td&gt;
              &lt;td&gt;Array&amp;lt;string&amp;gt; | &lt;code&gt;null&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The paths used to search for dependencies that are referenced in import statements in proto source files. If no import paths are provided then &amp;ldquo;.&amp;rdquo; (current directory) is assumed to be the only import path.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;protoFiles&lt;/td&gt;
              &lt;td&gt;Array&amp;lt;string&amp;gt;&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Rest parameters&lt;/a&gt; for the list of proto files to load/parse.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;examples&#34;&gt;Examples&lt;/h3&gt;
&lt;div class=&#34;code-group&#34; data-props=&#39;{&#34;labels&#34;: [&#34;Simple example&#34;], &#34;lineNumbers&#34;: [true]}&#39;&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import grpc from &amp;#39;k6/net/grpc&amp;#39;;

const client = new grpc.Client();
client.load([], &amp;#39;language_service.proto&amp;#39;);&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;code-group&#34; data-props=&#39;{&#34;labels&#34;: [&#34;More complex&#34;], &#34;lineNumbers&#34;: [true]}&#39;&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import grpc from &amp;#39;k6/net/grpc&amp;#39;;

const client = new grpc.Client();

client.load(
  [&amp;#39;../googleapis/google&amp;#39;],
  &amp;#39;spanner/admin/instance/v1/spanner_instance_admin.proto&amp;#39;,
  &amp;#39;spanner/admin/instance/v1/spanner_instance_admin.proto&amp;#39;,
  &amp;#39;spanner/v1/spanner.proto&amp;#39;
);&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="clientloadimportpaths-protofiles">Client.load(importPaths, &amp;hellip;protoFiles)&lt;/h1>
&lt;p>Loads and parses the protocol buffer descriptors so they are available to the client to marshal/unmarshal the correct request and response data structures for the RPC schema.&lt;/p></description></item><item><title>Client.loadProtoset(protosetPath)</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-net-grpc/client/client-loadprotoset/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-net-grpc/client/client-loadprotoset/</guid><content><![CDATA[&lt;h1 id=&#34;clientloadprotosetprotosetpath&#34;&gt;Client.loadProtoset(protosetPath)&lt;/h1&gt;
&lt;p&gt;Loads and parses the protoset file (serialized FileDescriptor set) so they are available to the client to marshal/unmarshal the correct request and response data structures for the RPC schema.&lt;/p&gt;
&lt;p&gt;Must be called within the 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/test-lifecycle/&#34;&gt;&lt;code&gt;init&lt;/code&gt; phase&lt;/a&gt;.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Parameter&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;protosetPath&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;The path of the protoset file. If no import paths are provided then &amp;ldquo;.&amp;rdquo; (current directory) is assumed to be the only import path.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;examples&#34;&gt;Examples&lt;/h3&gt;
&lt;div class=&#34;code-group&#34; data-props=&#39;{&#34;labels&#34;: [&#34;Simple example&#34;], &#34;lineNumbers&#34;: [true]}&#39;&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import grpc from &amp;#39;k6/net/grpc&amp;#39;;

const client = new grpc.Client();
client.loadProtoset(&amp;#39;./dummy.protoset&amp;#39;);&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="clientloadprotosetprotosetpath">Client.loadProtoset(protosetPath)&lt;/h1>
&lt;p>Loads and parses the protoset file (serialized FileDescriptor set) so they are available to the client to marshal/unmarshal the correct request and response data structures for the RPC schema.&lt;/p></description></item><item><title>Client.connect(address [,params])</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-net-grpc/client/client-connect/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-net-grpc/client/client-connect/</guid><content><![CDATA[&lt;h1 id=&#34;clientconnectaddress-params&#34;&gt;Client.connect(address [,params])&lt;/h1&gt;
&lt;p&gt;Opens a connection to a gRPC server; will block until a connection is made or a connection error is thrown. Cannot be called during the 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/test-lifecycle/&#34;&gt;&lt;code&gt;init&lt;/code&gt; phase&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;See 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-net-grpc/client/client-close/&#34;&gt;Client.close()&lt;/a&gt; to close the connection.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Parameter&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;address&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;The address of the gRPC server. Should be in the form: &lt;code&gt;host:port&lt;/code&gt; with no protocol prefix e.g. &lt;code&gt;grpc.k6.io:443&lt;/code&gt;. The host must be a literal IP address, or a host name that can be resolved to IP addresses. The port must be a literal port number or a service name e.g. &lt;code&gt;:443&lt;/code&gt; or &lt;code&gt;:https&lt;/code&gt;. If the host is a literal IPv6 address it must be enclosed in square brackets, as in &lt;code&gt;[2001:db8::1]:80&lt;/code&gt; or &lt;code&gt;[fe80::1%zone]:80&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;params (optional)&lt;/td&gt;
              &lt;td&gt;object&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;#connectparams&#34;&gt;ConnectParams&lt;/a&gt; object containing additional connect parameters.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;connectparams&#34;&gt;ConnectParams&lt;/h2&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;ConnectParams.plaintext&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;bool&lt;/td&gt;
              &lt;td&gt;If &lt;code&gt;true&lt;/code&gt; will connect to the gRPC server using plaintext i.e. insecure. Defaults to &lt;code&gt;false&lt;/code&gt; i.e. secure via TLS.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;ConnectParams.reflect&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;boolean&lt;/td&gt;
              &lt;td&gt;Whether to use the &lt;a href=&#34;https://github.com/grpc/grpc/blob/master/doc/server-reflection.md&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;gRPC server reflection protocol&lt;/a&gt; when connecting.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;ConnectParams.reflectMetadata&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;object&lt;/td&gt;
              &lt;td&gt;Object with key-value pairs representing custom metadata the user would like to add to the reflection request.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;ConnectParams.timeout&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string / number&lt;/td&gt;
              &lt;td&gt;Connection timeout to use. Default timeout is &lt;code&gt;&amp;quot;60s&amp;quot;&lt;/code&gt;. &lt;br/&gt; The type can also be a number, in which case k6 interprets it as milliseconds, e.g., &lt;code&gt;60000&lt;/code&gt; is equivalent to &lt;code&gt;&amp;quot;60s&amp;quot;&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;ConnectParams.maxReceiveSize&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;number&lt;/td&gt;
              &lt;td&gt;Sets the maximum message size in bytes the client can receive. Defaults to &lt;code&gt;grpc-go&lt;/code&gt; default, which is 4MB.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;ConnectParams.maxSendSize&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;number&lt;/td&gt;
              &lt;td&gt;Sets the maximum message size in bytes the client can send. Defaults to &lt;code&gt;grpc-go&lt;/code&gt; default, which is approximately 2GB.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;ConnectParams.tls&lt;/code&gt; (optional)&lt;/td&gt;
              &lt;td&gt;object&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;#tls&#34;&gt;TLS&lt;/a&gt; settings of the connection. Defaults to &lt;code&gt;null&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;tls&#34;&gt;TLS&lt;/h2&gt;
&lt;p&gt;TLS settings of the connection. If not defined, the main TLS config from options will be used.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;tls.cert&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;PEM formatted client certificate.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;tls.key&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;PEM formatted client private key.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;tls.password&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;Password for decrypting the client&amp;rsquo;s private key.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;tls.cacerts&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string / array&lt;/td&gt;
              &lt;td&gt;PEM formatted strings of the certificate authorities.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;examples&#34;&gt;Examples&lt;/h3&gt;
&lt;div class=&#34;code-group&#34; data-props=&#39;{&#34;labels&#34;: [&#34;Simple example&#34;], &#34;lineNumbers&#34;: [true]}&#39;&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import grpc from &amp;#39;k6/net/grpc&amp;#39;;

const client = new grpc.Client();

export default () =&amp;gt; {
  client.connect(&amp;#39;localhost:8080&amp;#39;);
};&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;code-group&#34; data-props=&#39;{&#34;labels&#34;: [&#34;Insecure connection&#34;], &#34;lineNumbers&#34;: [true]}&#39;&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import grpc from &amp;#39;k6/net/grpc&amp;#39;;

const client = new grpc.Client();

export default () =&amp;gt; {
  client.connect(&amp;#39;localhost:8080&amp;#39;, { plaintext: true });
};&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;code-group&#34; data-props=&#39;{&#34;labels&#34;: [&#34;Different TLS settings&#34;], &#34;lineNumbers&#34;: [true]}&#39;&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import grpc from &amp;#39;k6/net/grpc&amp;#39;;
import { check } from &amp;#39;k6&amp;#39;;
import { SharedArray } from &amp;#39;k6/data&amp;#39;;
import exec from &amp;#39;k6/execution&amp;#39;;

// note: the services in this example don&amp;#39;t exist. If you would like
// to run this example, make sure to replace the URLs, and
// the cacerts, cert, key, and password variables.
const grpcArgs = new SharedArray(&amp;#39;grpc&amp;#39;, () =&amp;gt; {
  // Using SharedArray here so that not every VU gets a copy of every certificate a key
  return [
    {
      host: &amp;#39;foo1.grpc-quickpizza.grafana.com:443&amp;#39;,
      plaintext: false,
      params: {
        tls: {
          cacerts: [open(&amp;#39;cacerts0.pem&amp;#39;)],
          cert: open(&amp;#39;cert0.pem&amp;#39;),
          key: open(&amp;#39;key0.pem&amp;#39;),
        },
      },
    },
    {
      host: &amp;#39;foo2.grpc-quickpizza.grafana.com:443&amp;#39;,
      params: {
        plaintext: false,
        tls: {
          cacerts: open(&amp;#39;cacerts1.pem&amp;#39;),
          cert: open(&amp;#39;cert1.pem&amp;#39;),
          key: open(&amp;#39;key1.pem&amp;#39;),
          password: &amp;#39;cert1-passphrase&amp;#39;,
        },
      },
    },
  ];
});

const client = new grpc.Client(null, &amp;#39;quickpizza.proto&amp;#39;);

export default () =&amp;gt; {
  if (__ITER === 0) {
    // Take one config and use it for this one VU
    const grpcArg = grpcArgs[exec.vu.idInTest % grpcArgs.length];
    client.connect(grpcArg.host, grpcArg.params);
  }

  const response = client.invoke(&amp;#39;quickpizza.GRPC/Status&amp;#39;);

  check(response, {
    &amp;#39;status is OK&amp;#39;: (r) =&amp;gt; r &amp;amp;&amp;amp; r.status === grpc.StatusOK,
  });

  console.log(JSON.stringify(response.message));
};&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="clientconnectaddress-params">Client.connect(address [,params])&lt;/h1>
&lt;p>Opens a connection to a gRPC server; will block until a connection is made or a connection error is thrown. Cannot be called during the
&lt;a href="/docs/k6/v2.3.x/using-k6/test-lifecycle/">&lt;code>init&lt;/code> phase&lt;/a>.&lt;/p></description></item><item><title>Client.asyncInvoke(url, request [,params])</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-net-grpc/client/client-async-invoke/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-net-grpc/client/client-async-invoke/</guid><content><![CDATA[&lt;h1 id=&#34;clientasyncinvokeurl-request-params&#34;&gt;Client.asyncInvoke(url, request [,params])&lt;/h1&gt;
&lt;p&gt;Asynchronously invokes an unary RPC request to the given method.&lt;/p&gt;
&lt;p&gt;The given method to invoke must have its RPC schema previously loaded via the 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-net-grpc/client/client-load/&#34;&gt;Client.load()&lt;/a&gt; function, otherwise an error will be thrown.&lt;/p&gt;
&lt;p&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-net-grpc/client/client-connect/&#34;&gt;Client.connect()&lt;/a&gt; must be called first before invoking a request, otherwise an error will be thrown.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Parameter&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;url&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;The gRPC method URL to invoke, in the form &lt;code&gt;/package.Service/Method&lt;/code&gt;, e.g. &lt;code&gt;/google.cloud.language.v1.LanguageService/AnalyzeSentiment&lt;/code&gt;. The leading slash &lt;code&gt;/&lt;/code&gt; is optional.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;request&lt;/td&gt;
              &lt;td&gt;object&lt;/td&gt;
              &lt;td&gt;The canonical request object, as-per the 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/protocols/grpc/#protocol-buffers-json-mapping&#34;&gt;Protobuf JSON Mapping&lt;/a&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;params (optional)&lt;/td&gt;
              &lt;td&gt;object&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-net-grpc/params/&#34;&gt;Params&lt;/a&gt; object containing additional request parameters.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;returns&#34;&gt;Returns&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;Promise with &lt;code&gt;Response&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;gRPC 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-net-grpc/response/&#34;&gt;Response&lt;/a&gt; object.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;examples&#34;&gt;Examples&lt;/h3&gt;
&lt;div class=&#34;code-group&#34; data-props=&#39;{&#34;labels&#34;: [&#34;Simple example&#34;], &#34;lineNumbers&#34;: [true]}&#39;&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import grpc from &amp;#39;k6/net/grpc&amp;#39;;
import { check } from &amp;#39;k6&amp;#39;;

const client = new grpc.Client();
client.load([], &amp;#39;routeguide.proto&amp;#39;);

export default () =&amp;gt; {
  client.connect(&amp;#39;localhost:10000&amp;#39;, { plaintext: true });

  client
    .asyncInvoke(&amp;#39;main.RouteGuide/GetFeature&amp;#39;, {
      latitude: 410248224,
      longitude: -747127767,
    })
    .then((response) =&amp;gt; {
      check(response, { &amp;#39;status is OK&amp;#39;: (r) =&amp;gt; r &amp;amp;&amp;amp; r.status === grpc.StatusOK });
      console.log(response.message.name);
      // output: 3 Hasta Way, Newton, NJ 07860, USA

      client.close();
    });
};&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="clientasyncinvokeurl-request-params">Client.asyncInvoke(url, request [,params])&lt;/h1>
&lt;p>Asynchronously invokes an unary RPC request to the given method.&lt;/p>
&lt;p>The given method to invoke must have its RPC schema previously loaded via the
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-net-grpc/client/client-load/">Client.load()&lt;/a> function, otherwise an error will be thrown.&lt;/p></description></item><item><title>Client.invoke(url, request [,params])</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-net-grpc/client/client-invoke/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-net-grpc/client/client-invoke/</guid><content><![CDATA[&lt;h1 id=&#34;clientinvokeurl-request-params&#34;&gt;Client.invoke(url, request [,params])&lt;/h1&gt;
&lt;p&gt;Invokes an unary RPC request to the given method.&lt;/p&gt;
&lt;p&gt;The given method to invoke must have its RPC schema previously loaded via the 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-net-grpc/client/client-load/&#34;&gt;Client.load()&lt;/a&gt; function, otherwise an
error will be thrown.&lt;/p&gt;
&lt;p&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-net-grpc/client/client-connect/&#34;&gt;Client.connect()&lt;/a&gt; must be called first before invoking a request, otherwise an error will be thrown.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Parameter&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;url&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;The gRPC method URL to invoke, in the form &lt;code&gt;/package.Service/Method&lt;/code&gt;, e.g. &lt;code&gt;/google.cloud.language.v1.LanguageService/AnalyzeSentiment&lt;/code&gt;. The leading slash &lt;code&gt;/&lt;/code&gt; is optional.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;request&lt;/td&gt;
              &lt;td&gt;object&lt;/td&gt;
              &lt;td&gt;The canonical request object, as-per the 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/protocols/grpc/#protocol-buffers-json-mapping&#34;&gt;Protobuf JSON Mapping&lt;/a&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;params (optional)&lt;/td&gt;
              &lt;td&gt;object&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-net-grpc/params/&#34;&gt;Params&lt;/a&gt; object containing additional request parameters.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;returns&#34;&gt;Returns&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Response&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;gRPC 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-net-grpc/response/&#34;&gt;Response&lt;/a&gt; object.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;examples&#34;&gt;Examples&lt;/h3&gt;
&lt;div class=&#34;code-group&#34; data-props=&#39;{&#34;labels&#34;: [&#34;Simple example&#34;], &#34;lineNumbers&#34;: [true]}&#39;&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import grpc from &amp;#39;k6/net/grpc&amp;#39;;
import { check } from &amp;#39;k6&amp;#39;;

const client = new grpc.Client();
client.load([], &amp;#39;routeguide.proto&amp;#39;);

export default () =&amp;gt; {
  client.connect(&amp;#39;localhost:10000&amp;#39;, { plaintext: true });
  const response = client.invoke(&amp;#39;main.RouteGuide/GetFeature&amp;#39;, {
    latitude: 410248224,
    longitude: -747127767,
  });
  check(response, { &amp;#39;status is OK&amp;#39;: (r) =&amp;gt; r &amp;amp;&amp;amp; r.status === grpc.StatusOK });
  console.log(response.message.name);
  // output: 3 Hasta Way, Newton, NJ 07860, USA

  client.close();
};&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="clientinvokeurl-request-params">Client.invoke(url, request [,params])&lt;/h1>
&lt;p>Invokes an unary RPC request to the given method.&lt;/p>
&lt;p>The given method to invoke must have its RPC schema previously loaded via the
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-net-grpc/client/client-load/">Client.load()&lt;/a> function, otherwise an
error will be thrown.&lt;/p></description></item><item><title>Client.close()</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-net-grpc/client/client-close/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-net-grpc/client/client-close/</guid><content><![CDATA[&lt;h1 id=&#34;clientclose&#34;&gt;Client.close()&lt;/h1&gt;
&lt;p&gt;Close the connection to the gRPC service. Tear down all underlying connections.&lt;/p&gt;
&lt;h3 id=&#34;examples&#34;&gt;Examples&lt;/h3&gt;
&lt;div class=&#34;code-group&#34; data-props=&#39;{&#34;labels&#34;: [&#34;Simple example&#34;], &#34;lineNumbers&#34;: [true]}&#39;&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import grpc from &amp;#39;k6/net/grpc&amp;#39;;

const client = new grpc.Client();
client.load([&amp;#39;definitions&amp;#39;], &amp;#39;hello.proto&amp;#39;);

export default () =&amp;gt; {
  client.connect(&amp;#39;localhost:8080&amp;#39;);
  client.close();
};&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="clientclose">Client.close()&lt;/h1>
&lt;p>Close the connection to the gRPC service. Tear down all underlying connections.&lt;/p>
&lt;h3 id="examples">Examples&lt;/h3>
&lt;div class="code-group" data-props='{"labels": ["Simple example"], "lineNumbers": [true]}'>
&lt;div class="code-snippet ">&lt;div class="lang-toolbar">
&lt;span class="lang-toolbar__item lang-toolbar__item-active">JavaScript&lt;/span>
&lt;span class="code-clipboard">
&lt;button x-data="app_code_snippet()" x-init="init()" @click="copy()">
&lt;img class="code-clipboard__icon" src="/media/images/icons/icon-copy-small-2.svg" alt="Copy code to clipboard" width="14" height="13">
&lt;span>Copy&lt;/span>
&lt;/button>
&lt;/span>
&lt;div class="lang-toolbar__border">&lt;/div>
&lt;/div>&lt;div class="code-snippet ">
&lt;pre data-expanded="false">&lt;code class="language-javascript">import grpc from &amp;#39;k6/net/grpc&amp;#39;;
const client = new grpc.Client();
client.load([&amp;#39;definitions&amp;#39;], &amp;#39;hello.proto&amp;#39;);
export default () =&amp;gt; {
client.connect(&amp;#39;localhost:8080&amp;#39;);
client.close();
};&lt;/code>&lt;/pre>
&lt;/div>
&lt;/div>
&lt;/div></description></item><item><title>Client.healthCheck()</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-net-grpc/client/client-health-check/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-net-grpc/client/client-health-check/</guid><content><![CDATA[&lt;h1 id=&#34;clienthealthcheckservice&#34;&gt;Client.healthCheck([service])&lt;/h1&gt;
&lt;p&gt;Check the health status of the gRPC service using the gRPC &lt;a href=&#34;https://grpc.io/docs/guides/health-checking/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Health Checking&lt;/a&gt; protocol.&lt;/p&gt;
&lt;p&gt;The method returns the health status of the provided service. If no service name is provided, it checks the overall server health.&lt;/p&gt;
&lt;p&gt;The health check response includes a &lt;code&gt;status&lt;/code&gt; field that can be one of the following constants:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;HealthCheckServing&lt;/code&gt;: The service is healthy and serving requests&lt;/li&gt;
&lt;li&gt;&lt;code&gt;HealthCheckNotServing&lt;/code&gt;: The service is not serving requests&lt;/li&gt;
&lt;li&gt;&lt;code&gt;HealthCheckUnknown&lt;/code&gt;: The health status is unknown&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;example&#34;&gt;Example&lt;/h3&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import grpc from &amp;#39;k6/net/grpc&amp;#39;;
import { check } from &amp;#39;k6&amp;#39;;

const client = new grpc.Client();
client.load([], &amp;#39;routeguide.proto&amp;#39;);

export default () =&amp;gt; {
  client.connect(&amp;#39;localhost:10000&amp;#39;, { plaintext: true });

  // Check overall server health
  const res = client.healthCheck();

  check(res, {
    &amp;#39;server is healthy&amp;#39;: (r) =&amp;gt; r &amp;amp;&amp;amp; r.status === grpc.StatusOK,
    &amp;#39;health status is serving&amp;#39;: (r) =&amp;gt; r &amp;amp;&amp;amp; r.message.status === grpc.HealthCheckServing,
  });

  // Check specific service health
  const svcRes = client.healthCheck(&amp;#39;my.service.Name&amp;#39;);
  console.log(&amp;#39;Health status:&amp;#39;, svcRes.message.status);

  client.close();
};&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="clienthealthcheckservice">Client.healthCheck([service])&lt;/h1>
&lt;p>Check the health status of the gRPC service using the gRPC &lt;a href="https://grpc.io/docs/guides/health-checking/" target="_blank" rel="noopener noreferrer">Health Checking&lt;/a> protocol.&lt;/p>
&lt;p>The method returns the health status of the provided service. If no service name is provided, it checks the overall server health.&lt;/p></description></item></channel></rss>