nodejs / nodejs/node

Unix Domain Socket doesn't support on Windows

Đang mở
#55,979 7 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

libuv windows
Ngôn ngữ chính
JavaScript
Star
122k
Fork
37.4k
Merge trung bình
4 ngày 2 giờ
Pull request đã merge (30 ngày)
283

Mô tả

Version

20.18.0

Platform
Microsoft Windows NT 10.0.26100.0 x64
Subsystem

No response

What steps will reproduce the bug?

Currently, Windows (at least .NET) supports connect to UnixDomainSocket, or listen to UnixDomainSocket in ASP.NET Core. But node's net module seems not support connect to a Windows local file.

public class UnixDomainSocketsConnectionFactory(EndPoint endPoint) {
   public async ValueTask<Stream> ConnectAsync(SocketsHttpConnectionContext _,
      CancellationToken cancellationToken = default) {
      var socket = new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.Unspecified);

      try {
         await socket.ConnectAsync(endPoint, cancellationToken).ConfigureAwait(false);
         return new NetworkStream(socket, true);
      } catch {
         socket.Dispose();
         throw;
      }
   }

   public static GrpcChannel CreateChannel(string socketPath) {
      var udsEndPoint = new UnixDomainSocketEndPoint(socketPath);
      var connectionFactory = new UnixDomainSocketsConnectionFactory(udsEndPoint);
      var socketsHttpHandler = new SocketsHttpHandler {
         ConnectCallback = connectionFactory.ConnectAsync
      };

      return GrpcChannel.ForAddress("http://localhost", new GrpcChannelOptions {
         HttpHandler = socketsHttpHandler
      });
   }
}
   protected void Initialize(string token) {
      var builder = WebApplication.CreateBuilder();
      builder.WebHost.ConfigureKestrel(serverOptions => {
         if (!Directory.Exists(MetaBoxStatic.UnixSocketPath)) {
            Directory.CreateDirectory(MetaBoxStatic.UnixSocketPath);
         }

         var socketPath = Path.Combine(MetaBoxStatic.UnixSocketPath, $"MetaBox-{token}.tmp");
         serverOptions.ListenUnixSocket(socketPath);
         serverOptions.ConfigureEndpointDefaults(listenOptions => { listenOptions.Protocols = HttpProtocols.Http2; });
      });

      ConfigureBuilder(builder);
      builder.Services.PostConfigureAll<HostOptions>(opts => opts.ShutdownTimeout = TimeSpan.FromSeconds(1));

      WebApp = builder.Build();
      ConfigureApp(WebApp);
   }
How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

The net connects to the "Windows" UnixDomainSocket as it could.

What do you see instead?

EACCESS / ENOENT

Additional information

No response

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng việc xem xét cách module net của Node.js xử lý Unix domain socket trên Windows và tái hiện lỗi bằng các ví dụ Windows và .NET được cung cấp. Công việc được xem là hoàn tất khi Node có thể kết nối tới và lắng nghe trên Windows UnixDomainSocket, đồng thời các lỗi EACCESS và ENOENT được báo cáo đã được giải quyết; thêm hoặc chạy các bài kiểm thử dành riêng cho nền tảng có liên quan nếu có.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript, nodejs
Lĩnh vực
networking, operating-systems
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.