fullstorydev / grpcurl

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

Hanging on reflection when calling method #319

Open MattIPv4 opened 2 years ago

MattIPv4 commented 2 years ago

👋 I'm not sure if this is an issue with grpcurl or with my demo code (though I don't immediately see anything wrong with the latter).

I am running a very basic demo gRPC server in Node.js with server reflection implemented, and when attempting to call the demo greeter method in the server grpcurl seems to make a reflection request as expected first, but then leaves this connection open and never makes the actual method request.

The demo server I'm using is here: https://github.com/MattIPv4/node-grpc-server

gprcurl can successfully list all the services on the server, and list the methods of the greeter service, but fails on the final command to actually invoke the greeter method.

Any help would be much appreciated ❤️

dragonsinth commented 2 years ago

@MattIPv4 I'm guessing there's some kind of subtle difference between the Go gRPC server implementation and the Node gRPC server implementation you're using. It's possible that grpcurl / the Go gRPC client libs are insufficiently general, but I would tend to suspect the Node server first. Either way, I think digging in and debugging is probably the only way to figure out what's happening under the hood.

MattIPv4 commented 2 years ago

👀 So I had a chance to do some more digging today, and it seems that this might be an issue isolated to a specific terminal! I've been trialling Warp for a while now, and this is where I was running into the issue:

grpcurl -vv -plaintext -d '{"name":"test"}' localhost:3000 greeter.Greeter.SayHello

Resolved method descriptor:
rpc SayHello ( .greeter.HelloRequest ) returns ( .greeter.HelloReply );

Request metadata to send:
(empty)
Demo server logs observed during this ``` Reflection request started Reflection request data { fileContainingSymbol: 'greeter.Greeter' } Sent fileDescriptorResponse for greeter.proto ```

It hangs at this point and doesn't do anything more, I can ctrl+c to abort at which point I see the reflection stream close in the gRPC server.

I've just tried this in the default terminal app instead of Warp (happened to be using the terminal for something else), and it seems to work just fine there:

grpcurl -vv -plaintext -d '{"name":"test"}' localhost:3000 greeter.Greeter.SayHello

Resolved method descriptor:
rpc SayHello ( .greeter.HelloRequest ) returns ( .greeter.HelloReply );

Request metadata to send:
(empty)

Response headers received:
content-type: application/grpc+proto
date: Thu, 07 Jul 2022 22:12:15 GMT
grpc-accept-encoding: identity,deflate,gzip

Estimated response size: 13 bytes

Response contents:
{
  "message": "Hello, test"
}

Response trailers received:
(empty)
Sent 1 request and received 1 response
Demo server logs observed during this ``` Reflection request started Reflection request data { fileContainingSymbol: 'greeter.Greeter' } Sent fileDescriptorResponse for greeter.proto Responded to sayHello for test Reflection request ended Reflection request cancelled ```

Now I'm even more confused! I'm not sure if this is an issue with grpcurl, or something super funky with Warp. Let me know if you think I should report this over to them rather than y'all.

It seems like this isn't an issue with grpc-js though, so I'll close out the issue over there.

re-mscho commented 1 year ago

I had the same hang for a server implemented in python. Maybe your problem is completely different but for me the cause was that the server was configured single threaded so it could handle only one message at a time. It looks like to get the request working using reflection is to allow the server to handle multiple requests in parallel.

Perhaps this information can assist in pinpointing the source of your error.