cyanfish / grpc-dotnet-namedpipes

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

Curious about not working on Linux #19

Closed lsylusiyao closed 1 year ago

lsylusiyao commented 3 years ago

I've tried a very simple example which could easily run on Windows, but on Linux, client couldn't connect to server. I've checked the source code on git and it seems that there's no Interop about Windows API. I know this is targeting Windows but I'm very curious about why this package doesn't work well on Linux. Is there any suggestions about making it work on Linux? Thanks.

cyanfish commented 3 years ago

It might be related to this? https://stackoverflow.com/questions/46683772/issue-with-net-core-named-pipes-on-linux-address-already-in-use

lsylusiyao commented 3 years ago

I've checked the source code of System.IO.Pipes. It seems that the problem you've mentioned above has fixed so it shouldn't be the reason of not working on Linux.

Though the absolute name of the name pipes are different between Windows and Unix, the server and client use the same name on one platform, so it shouldn't be the problem of name's difference.

What's more, through the source code I've found that dotnet created a name pipe called /tmp/CoreFx_SOMENAME, but when I ls inside /tmp, the only thing I've got about dotnet is a list of clr-debug-pipe-*** and dotnet-diagnostic-***. I'm confused about this. Thanks.

PS: I've tested this on WSL2, Win10 20H2

lsylusiyao commented 3 years ago

I find out that the true problem of not working on nix is that, when creating the NamedPipeServerStream, PipeTransmissionMode.Message is used which is not supported on nix (ServerStreamPool.cs). Maybe one of the reason using the Message is it's a quick way of receiving data from pipe. I don't really understand how gRPC deals with message, but I find a way from a similar project which adds some bytes in front of the stream to indicate the whole transforming bytes. This might be a way of making this project work on *nix.

cyanfish commented 1 year ago

Linux (and Mac) support should now work in 2.0.0.