cyanfish / grpc-dotnet-namedpipes

Named pipe transport for gRPC in C#/.NET
Apache License 2.0
190 stars 48 forks source link

May need a timeout on client read (appears to be infinite?) #17

Closed rmacfadyen closed 1 year ago

rmacfadyen commented 3 years ago

Trying this out and I put together some very bad code that was hard to figure out why things were going wrong.

The main symptom was that a client would wait perpetually for a response after successfully sending a message. The server would never receive a message. No errors, no exceptions. I didn't wait very long, a few minutes.

The underlying cause was bad code binding the server:

var server = new NamedPipeServer("MyPipeName");
MyService.BindService(new MyServiceService());

It should have been:

var server = new NamedPipeServer("MyPipeName");
MyService.BindService(server.ServiceBinder, new MyServiceService());

Everything worked "fine" except this never returns:

var channel = new NamedPipeChannel(".", "Test");
var ServiceClient = new MyService.MyServiceClient(channel);
var response = await ServiceClient.SendMessageAsync(new SomeMessaget() { Name = "bugger" });

No errors or exceptions I could find.

cyanfish commented 3 years ago

I can consider changing the defaults, but there is a client timeout option: https://github.com/cyanfish/grpc-dotnet-namedpipes/blob/043cead5ba3d0e3fb746160dc7e71729a66d657c/GrpcDotNetNamedPipes/NamedPipeChannelOptions.cs#L40

rmacfadyen commented 3 years ago

Thanks!

I think that a default of a few seconds would be more helpful. Maybe even 30 seconds at the outside?

cyanfish commented 1 year ago

I added a 30s default timeout in 2.0.0.