Unix Domain Socket doesn't support on Windows
未关闭
还没有人认领这个 Issue。
libuv
windows
- 主要语言
- JavaScript
- 星标
- 122k
- 派生
- 37.4k
- 平均合并
- 4 天 2 小时
- 30 天内合并 PR
- 283
描述
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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 Node.js 的 net 模块处理 Windows 上 Unix 域套接字的方式入手,并使用提供的 Windows 和 .NET 示例重现该故障。完成标准是 Node 能够连接到 Windows UnixDomainSocket 并在其上监听,同时解决报告的 EACCESS 和 ENOENT 错误;如果有可用的相关平台特定测试,请添加或运行这些测试。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, nodejs
- 领域
- networking, operating-systems
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100