Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Symbol not found" when running gRPCox in Docker/K8s #13

Open
trenslow opened this issue Dec 4, 2019 · 7 comments
Open

"Symbol not found" when running gRPCox in Docker/K8s #13

trenslow opened this issue Dec 4, 2019 · 7 comments

Comments

@trenslow
Copy link

trenslow commented Dec 4, 2019

Hi,

First off, wanted to say nice job on the gRPCox tool. It's super handy for gRPC development.

I would like to run gRPCox on Kubernetes, in order to test the connection between the client and the server. When I run the gRPC reflection-enabled server on my local machine, I have no problems communicating with it using gRPCox. However, when I run the server in either a Docker container or Kubernetes, I get a strange error.

Using gRPCox I can choose the service. But when I choose one of the methods, I get an error: "Symbol not found: " (see screenshot below).

Annotation 2019-12-04 173427

I suspect it may have to do with the way my server's environment is configured in its Docker container, but I don't know where to start. Could you please advise on this issue?

Thanks!

@gusaul
Copy link
Owner

gusaul commented Dec 5, 2019

I think its not related with your app environment (docker & k8s).. its should be related with either your gRPC server reflection or protoc generator..

what your gRPC server language?
what protoc generator you're using?

@trenslow
Copy link
Author

trenslow commented Dec 5, 2019

update on the environment story: I ran evans CLI from another pod in k8s and was able to access all the messages, rpcs, etc. and even call the rpcs without any issue. I also now agree that it's not the app environment.

My server's language is Python and I used the Python grpc-tools package to generate my proto code, as per the grpc documentation. I somehow doubt that it's the generator, because it works in every other environment that I can try. But I do agree that it could be the configuration of server reflection.

I'm using the same code from this documentation here. Maybe something extra needs to be configured so that gRPCox can discover everything.

@gusaul
Copy link
Owner

gusaul commented Dec 5, 2019

could you share your .proto file? at least for that failing methods?

@trenslow
Copy link
Author

trenslow commented Dec 5, 2019

I'm not really allowed to share the proto file, but I can tell you that all methods are failing. I can provide information about what the shape of the messages is, if that's helpful.

@aultokped
Copy link
Collaborator

is there any import from external proto?

@trenslow
Copy link
Author

Nope, no imports!

@paskozdilar
Copy link

paskozdilar commented Mar 7, 2024

I have the same problem with a very simple proto file:

syntax = "proto3";

package example_package;

message ServerMessage {
  oneof server_message {
    string a = 1;
    string b = 2;
  };
}

message ClientMessage {
  oneof client_message {
    string a = 1;
    string b = 2;
  };
}

service Example {
  rpc unaryCall(ClientMessage) returns (ServerMessage) {}
  rpc serverStreamingCall(ClientMessage) returns (stream ServerMessage) {}
  rpc clientStreamingCall(stream ClientMessage) returns (ServerMessage) {}
  rpc bidirectionalStreamingCall(stream ClientMessage) returns (stream ServerMessage) {}
}

With the proto file located in ./proto/ directory, I have compiled it with command:

proto-loader-gen-types --longs=String --enums=String --defaults --oneofs --grpcLib=@grpc/grpc-js --outDir=proto/ proto/*.proto

Here's the server code in typescript:

import * as grpc from '@grpc/grpc-js';
import * as protoLoader from '@grpc/proto-loader';
import * as reflection from '@grpc/reflection';
import { ProtoGrpcType } from './proto/example';
import { ClientMessage } from './proto/example_package/ClientMessage';
import { ExampleHandlers } from './proto/example_package/Example';
import { ServerMessage } from './proto/example_package/ServerMessage';

const host = '0.0.0.0:9090';

const exampleServer: ExampleHandlers = {
  unaryCall(
    call: grpc.ServerUnaryCall<ClientMessage, ServerMessage>,
    callback: grpc.sendUnaryData<ServerMessage>
  ) {
    if (call.request) {
      console.log(`(server) Got client message: ${call.request.clientMessage}`);
    }
    callback(null, {
      b: 'Message from server',
    });
  },

  serverStreamingCall(
    call: grpc.ServerWritableStream<ClientMessage, ServerMessage>
  ) {
    call.write({
      b: 'Message from server',
    });
    call.end();
  },

  clientStreamingCall(
    call: grpc.ServerReadableStream<ClientMessage, ServerMessage>
  ) {
    call.on('data', (clientMessage: ClientMessage) => {
      console.log(
        `(server) Got client message: ${clientMessage.clientMessage}`
      );
    });
  },

  bidirectionalStreamingCall(
    call: grpc.ServerDuplexStream<ClientMessage, ServerMessage>
  ) {
    call.write({
      b: 'Message from server',
    });
    call.on('data', (clientMessage: ClientMessage) => {
      console.log(
        `(server) Got client message: ${clientMessage.clientMessage}`
      );
    });
  },
};

function getServer(): grpc.Server {
  const packageDefinition = protoLoader.loadSync('./proto/example.proto', {
    longs: String,
    enums: String,
    defaults: true,
    oneofs: true,
  });
  const proto = grpc.loadPackageDefinition(
    packageDefinition
  ) as unknown as ProtoGrpcType;
  const server = new grpc.Server();

  const reflect = new reflection.ReflectionService(packageDefinition);
  reflect.addToServer(server);

  server.addService(proto.example_package.Example.service, exampleServer);
  return server;
}

if (require.main === module) {
  const server = getServer();
  server.bindAsync(
    host,
    grpc.ServerCredentials.createInsecure(),
    (err: Error | null, port: number) => {
      if (err) {
        console.error(`Server error: ${err.message}`);
      } else {
        console.log(`Server bound on port: ${port}`);
        server.start();
      }
    }
  );
}

I'm running grpcox with the following command:

docker run --net=host gusaul/grpcox

UI output:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants