fullstorydev / grpcurl

Like cURL, but for gRPC: Command-line tool for interacting with gRPC servers
MIT License
10.36k stars 497 forks source link

Can list services but can't invoke service #358

Closed paymog closed 1 year ago

paymog commented 1 year ago

I have a grpc service running and I can successfully use grpcurl to list the services it exposes:

root@firehose-mainnet-reader-5695bc9d76-8vnhd:/firehose-ethereum# ../grpcurl -plaintext localhost:13010 list
grpc.reflection.v1alpha.ServerReflection
sf.bstream.v1.BlockStream
sf.ethereum.trxstream.v1.TransactionStream
sf.headinfo.v1.HeadInfo

However, when I try to invoke the TransactionStream I get an error:

root@firehose-mainnet-reader-5695bc9d76-8vnhd:/firehose-ethereum# ../grpcurl -plaintext  localhost:13010 sf.ethereum.trxstream.v1.TransactionStream
Error invoking method "sf.ethereum.trxstream.v1.TransactionStream": target server does not expose service "sf.ethereum.trxstream.v1"

this also happens when I try to include the proto files in the invocation:

root@firehose-mainnet-reader-5695bc9d76-8vnhd:/firehose-ethereum# ../grpcurl -plaintext -import-path ./proto -proto ./proto/sf/ethereum/trxstream/v1/trxstream.proto localhost:13010 sf.ethereum.trxstream.v1.TransactionStream
Error invoking method "sf.ethereum.trxstream.v1.TransactionStream": target server does not expose service "sf.ethereum.trxstream.v1"

The proto file can be found here.

Note that the above commands are being invoked from the root of the repository linked above.

jhump commented 1 year ago

@paymog, when you use the list command, it shows you the list of services. You can then list an individual service to see its list of methods:

../grpcurl -plaintext localhost:13010 list sf.ethereum.trxstream.v1.TransactionStream

(You could also describe the service and see more information than just a list of method names.)

Looking at the proto source file you linked, the above command would show you a single method:

sf.ethereum.trxstream.v1.TransactionStream.Transactions

So to invoke the RPC, you need this name -- the method name, not a service name. The error message is because grpcurl is trying to parse the method name you provided and decided that it's a method named "TransactionStream" and a service named "sf.ethereum.trxstream.v1", which is incorrect (hence the error).

paymog commented 1 year ago

d'oh, what a silly mistake by me. Thanks for the help. ❤️