GRPC with server reflection (python-server with \"google/protobuf/wrappers.proto\")

Hello,
I’m trying to test a call python grpc server with k6.

I go the following result:

stant-vus scenario=default source=stacktrace

time="2023-06-18T15:57:12Z" level=info msg="Out Header:\nFull Method: /grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo\nRemote Address: 172.16.238.13:50052\nuser-agent: grpc-go/1.53.0\n\n" source=http-debug
time="2023-06-18T15:57:12Z" level=info msg="In Header:\nWire Length: 78\ncontent-type: application/grpc\ngrpc-accept-encoding: identity, deflate, gzip\n\n" source=http-debug
time="2023-06-18T15:57:12Z" level=error msg="GoError: can't convert method info: proto:\u00a0could not resolve import \"google/protobuf/wrappers.proto\": not found\n\tat 
reflect.methodValueCall (native)\n\tat file:///scripts/test4.js:15:17(9)\n" executor=constant-vus scenario=default source=stacktrace

What does that mean? The reflection work well for the use with postman?
Did someone also have that problem?

Hi @andife

Welcome to the community forums! :wave:

Could you please provide a sample of your script or at least the Client.connect part?

Cheers!

Hi, thank you!

import grpc from 'k6/net/grpc';
import { check, sleep } from 'k6';
export const options = {
  vus:1,
  duration:"40s"
}

const client = new grpc.Client();

console.log(client);

client.load(['./definitions'], 'com.api_pred.proto', 'com.api_db.proto', 'com.base.proto');

export default () => {
  client.connect("172.16.138.13:50052", { reflect: true , 
     plaintext: true
  });

Invoke is done by:

const response = client.invoke(‘com.api_pred.PrToHost/PStartModel’, data);

I can imagine that it is difficult to answer, since my information is not so complete after all.

The requested files could be found at [protobuf/src/google/protobuf/wrappers.proto at main · protocolbuffers/protobuf · GitHub](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/wrappers.proto.

Do I have to integrate that with client.load? Or should they be available via reflection?

Hey @andife

When you use a reflection, you don’t need to load any proto files. So basically, you don’t need to call the client.load and still should be able to call invoke. See our example there https://github.com/grafana/k6/blob/master/examples/grpc_reflection.js

An important thing is that reflection should be enabled on a server. Is that the case? To prove that you can for instance try grpcurl tool. And run something like:

grpcurl -plaintext 172.16.138.13:50052 list

Could you please confirm that this works?

Cheers

1 Like

Yes reflection is activated on the server (and it works using postman)

Outside from docker-compose I execute

grpcurl --plaintext localhost:5001 list

and I get

com.api_pred.PrToHost
grpc.reflection.v1alpha.ServerReflection

Thank you

Maybe it relates to " Reflection does not work if proto contains import · Issue #32821 · grpc/grpc (github.com)"

Hi @andife

:thinking: so yeah, reflection works.

And thanks for sharing Reflection does not work if proto contains import · Issue #32821 · grpc/grpc · GitHub. It could be related, so I’ll try to investigate it more profoundly.

I’ll update here after it.

Thanks!

1 Like