dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.58k stars 4.55k forks source link

Named pipes on MacOS can't connect in .NET 8 #101366

Open Jasper2213 opened 2 months ago

Jasper2213 commented 2 months ago

Description

I'm trying to use named pipes in .NET MAUI, but when testing on MacOS, the client can't connect to the server, it just hangs on connect.

When running the project with .NET 7, the client connects to the server on both Windows and MacOS.

Reproduction Steps

  1. Clone the reproduction repo
  2. Open the net-8 solution
  3. Run the Server and Client at the same time

Expected behavior

Client connects to Server and Server can send a message to Client

Actual behavior

Client can't connect to Server, instead hangs at _pipeClient.ConnectAsync()

Regression?

Worked on .NET 7, doesn't work on .NET 8.

Known Workarounds

No response

Configuration

No response

Other information

No response

dotnet-policy-service[bot] commented 2 months ago

Tagging subscribers to this area: @dotnet/ncl See info in area-owners.md if you want to be subscribed.

rzikm commented 2 months ago

The type in question is NamedPipeClientStream. Moving to System.IO area.

dotnet-policy-service[bot] commented 2 months ago

Tagging subscribers to this area: @dotnet/area-system-io See info in area-owners.md if you want to be subscribed.

dotnet-policy-service[bot] commented 2 months ago

Tagging subscribers to this area: @dotnet/ncl See info in area-owners.md if you want to be subscribed.

dotnet-policy-service[bot] commented 2 months ago

Tagging subscribers to this area: @dotnet/area-system-io See info in area-owners.md if you want to be subscribed.

wfurt commented 2 months ago

I commented on wrong issue. It can still be Socket problem as the Named Pipes use unix domain socket under the cover.

wfurt commented 2 months ago

Your code is different between 7 and 8 versions @Jasper2213. At least in the provided example the 7.0 project use ConnectAsync and the InitPipeClient is marked as async so it will never block and hang on thread pool.

In 8.0 you use synchronous connect and that will block everything until connected until connected. In my quick test I did not have server running yet but the application hangs in weird state while 7.0 looks responsive .... even if the socket is not actually connected.,

When I make the 7.0 and 8.0 version same I see same behavior e.g. I do not see regression.

Jasper2213 commented 2 months ago

I updated the code in the .NET 8 project to match that of the .NET 7 project (can't believe I missed that). This indeed doesn't fix the problem.