# gRPC: Import nested proto files

**URL:** <https://community.grafana.com/t/grpc-import-nested-proto-files/97819>\
**Category:** OSS Support\
**Created:** [October 4, 2022, 11:14am UTC](https://community.grafana.com/t/grpc-import-nested-proto-files/97819 "2022-10-04T11:14:48Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![BratSinot](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@BratSinot](https://community.grafana.com/u/BratSinot)\
**Post date:** [October 4, 2022, 11:14am UTC](https://community.grafana.com/t/grpc-import-nested-proto-files/97819/1 "2022-10-04T11:14:48Z")

</div>

Greetings!

I try to use gRPC client like this:

```go
const client = new grpc.Client();
client.load(
    [PROTO_PATH] // some global path
    , "service.proto"
);

<...>

export default () => {
    client.connect(`${HOST}:${GRPC_PORT}`, {
        plaintext: true
    });

    const response = client.invoke("<req_name>", {
        <data>
    });
    check(response, {
        'status is OK': (r) => r && r.status === grpc.StatusOK,
    });

    log(JSON.stringify(response));

    client.close();
}

```

But getting error:

```plaintext
ERRO[0000] GoError: method "/<req_name>" not found in file descriptors
	at reflect.methodValueCall (native)
	at O (webpack://k6-test/./src/main.js:49:22(27))
	at native executor=shared-iterations scenario=default source=stacktrace

```

And I can’t get why I got this error. My proto file split into several, may it cause problem? Does k6 support `import` in proto?

---

<div class="post-metadata">

**Author:** ![olegbespalov](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/olegbespalov/32/36739_2.png) [@olegbespalov](https://community.grafana.com/u/olegbespalov)\
**Post date:** [October 10, 2022, 8:59am UTC](https://community.grafana.com/t/grpc-import-nested-proto-files/97819/3 "2022-10-10T08:59:30Z")

</div>

Hi @BratSinot !

Sorry for the delay.

Do all your proto files located in the PROTO\_PATH:

> [@BratSinot](#):
>
> `[PROTO_PATH] // some global path`

🤔

Could you maybe provide more details on how you use imports?

Thanks,  
Cheers!

---

<div class="post-metadata">

**Author:** ![Amit00p](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@Amit00p](https://community.grafana.com/u/Amit00p)\
**Post date:** [January 11, 2023, 9:03am UTC](https://community.grafana.com/t/grpc-import-nested-proto-files/97819/5 "2023-01-11T09:03:41Z")

</div>

Hi @olegbespalov ,

I have tried to use the GRPC client same way used by @BratSinot and i have given the [PROTO\_PATH] also but its not working giving the same error.

To execute the js file i’m using grafana/k6 .

docker run --rm -i -v “$PWD:/src” grafana/k6 run /src/grpcAi.js

ERROR after this.

level=error msg=“GoError: connection error: desc = "transport: error while dialing: dial tcp 127.0.0.1:50051: connect: connection refused"\n\tat reflect.methodValueCall (native)\n\tat file:///src/grpcAi.js:9:36(6)\n\tat native\n” executor=per-vu-iterations scenario=default source=stacktrace

---

<div class="post-metadata">

**Author:** ![olegbespalov](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/olegbespalov/32/36739_2.png) [@olegbespalov](https://community.grafana.com/u/olegbespalov)\
**Post date:** [January 11, 2023, 9:11am UTC](https://community.grafana.com/t/grpc-import-nested-proto-files/97819/6 "2023-01-11T09:11:32Z")

</div>

Hi @Amit00p !

As I can see from the log record that you’ve provided, an error is different:

```auto
transport: error while dialing: dial tcp 127.0.0.1:50051: connect: connection refused

```

The k6 from inside docker can’t reach the target service at the `127.0.0.1:50051`

Cheers

---

<div class="post-metadata">

**Author:** ![Amit00p](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@Amit00p](https://community.grafana.com/u/Amit00p)\
**Post date:** [January 11, 2023, 10:43am UTC](https://community.grafana.com/t/grpc-import-nested-proto-files/97819/7 "2023-01-11T10:43:41Z")

</div>

Hi @olegbespalov ,

Can you please help me to understand how can we connect to IP address outside the docker from the inside for the given case.

---

<div class="post-metadata">

**Author:** ![olegbespalov](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/olegbespalov/32/36739_2.png) [@olegbespalov](https://community.grafana.com/u/olegbespalov)\
**Post date:** [January 11, 2023, 12:31pm UTC](https://community.grafana.com/t/grpc-import-nested-proto-files/97819/8 "2023-01-11T12:31:01Z")

</div>

Hey @Amit00p !

You better have a look at a docker documentation, like [docker run | Docker Documentation](https://docs.docker.com/engine/reference/commandline/run/#-add-entries-to-container-hosts-file---add-host)

But I guess something like:

```auto
 docker run --rm -i \
  --add-host=test.localhost:host-gateway \
  -v "$PWD:/src" grafana/k6 run /src/grpcAi.js

```

It could probably work, and then from inside the scripts, you can try to request `test.localhost:50051`

Cheers

---

<div class="post-metadata">

**Author:** ![alex2](https://avatars.discourse-cdn.com/v4/letter/a/45deac/32.png) [@alex2](https://community.grafana.com/u/alex2)\
**Post date:** [May 26, 2023, 4:15pm UTC](https://community.grafana.com/t/grpc-import-nested-proto-files/97819/9 "2023-05-26T16:15:20Z")

</div>

Hey there!

I landed on that topic looking for solution of loading nested protofiles, so i’ll just ask haha.

I’ve got a custom test.proto file

`import “google/api/annotations.proto”;

message Test {  
string a = 1;  
}

service TestMethods {  
rpc Test(Test) returns (Test) {  
option (google.api.http) = {  
post: “…”  
body: “\*”  
};  
}

and a test.js k6 script file:

import grpc from ‘k6/net/grpc’;

const client = new grpc.Client();  
client.load([‘…/…/…/proto’], ‘/test.proto’);

but i found no way loading `google/api/annotations.proto` into my file, it keep complaining about ‘annotations.proto’ no such file or directory

How can i load annotations.proto in my file when its not part of my ‘…/…proto’ directory.  
Thanks in advance !

---

<div class="post-metadata">

**Author:** ![andife](https://avatars.discourse-cdn.com/v4/letter/a/85e7bf/32.png) [@andife](https://community.grafana.com/u/andife)\
**Post date:** [June 23, 2023, 5:39pm UTC](https://community.grafana.com/t/grpc-import-nested-proto-files/97819/11 "2023-06-23T17:39:40Z")

</div>

I’ve the same problem. Did you solve the problem? Maybe by copying th google files relative to your files? (I was not successful with that try)

---

<div class="post-metadata">

**Author:** ![alex2](https://avatars.discourse-cdn.com/v4/letter/a/45deac/32.png) [@alex2](https://community.grafana.com/u/alex2)\
**Post date:** [June 23, 2023, 6:01pm UTC](https://community.grafana.com/t/grpc-import-nested-proto-files/97819/12 "2023-06-23T18:01:45Z")

</div>

Hey, no, i havent solved the problem, i just copied the same file form y repo into my x repo and i removed the import and the usage of the import, and this is how i use it atm. Couldnt find solution for too long, to continue loosing more time…  
Probably with copying the google files might do the job but version incompatibility would be a nightmare to manage…
