grpc_client icon indicating copy to clipboard operation
grpc_client copied to clipboard

Generated client code fails with "unknown service" error

Open galaxie opened this issue 7 years ago • 0 comments

I was trying to generate ETCD3 client using the specification attached and Erlang/OTP 20 on MacOS High Sierra.

Generated code fails with unknown service error.

Here is the scenario. Protobuff specification resides in ./proto dir:

.
├── proto
│   ├── etcd_auth.txt
│   ├── etcd_kv.txt
│   └── etcd_rpc.txt
├── src
    ├── ...
├── Makefile
├── ...

I generated code using the following command:

% ProtoDir = "absolute path to proto dir".

grpc_client:compile(
        filename:join(ProtoDir, "etcd_rpc.txt"),
        [
            {i, ProtoDir},
            {use_packages, true}
        ]
    ).
ok

Then I put all two generated files (etcd_rpc_client.erl and etcd_rpc.erl) in ./src dir of my project and try to run the code:

{ok, Connection} = grpc_client:connect(tcp, "localhost", 2379).
etcd_rpc_client:'Put'(Connection, #{key => "foo", value => "bar"}, []).
{error,#{error_type => grpc,grpc_status => 12,headers => #{},
         http_status => 200,result => #{},
         status_message =>
             <<"unknown service etcdserverpb.etcdserverpb.KV">>,
         trailers =>
             #{<<":status">> => <<"200">>,
               <<"content-type">> => <<"application/grpc">>,
               <<"grpc-message">> =>
                   <<"unknown service etcdserverpb.etcdserverpb.KV">>,
               <<"grpc-status">> => <<"12">>}}}

etcd_rpc.txt etcd_auth.txt etcd_kv.txt

galaxie avatar Jun 11 '18 11:06 galaxie