没有 ASP.Net 的 grpc-dotnet 服务器

xTe*_*are 5 server .net-core grpc

我目前正在尝试将我的项目 (.Net Core) 从“Grpc.Core”移植到“grpc-dotnet”,因为 Grpc.Core 现在处于维护模式,将在大约一年后被弃用。

项目由多项服务组成。客户端和服务器。

移植客户端部分没问题,但是如何在没有Asp.Net 的情况下使用 grpc-dotnet 创建服务器?

当前的实现如下所示

using Grpc.Core;
using ProtoBuf.Grpc.Server;

...

private Grpc.Core.Server CreateServer()
{
    Server server = new Server
    {
        Ports = {new ServerPort(_Configuration.Host, _Configuration.Port, ServerCredentials.Insecure)}
    };
    
    return server;
}
Run Code Online (Sandbox Code Playgroud)

服务器提供的服务在 ProtoBuf.Grpc.Server 中注册为 Code-First。

是否支持或将支持 Asp.Net 之外的服务器?

Pat*_*ens 3

我非常希望情况并非如此,但恐怕答案是你不能。这个问题经常被问到(https://github.com/grpc/grpc-dotnet/issues/1368,https://github.com/grpc/grpc-dotnet/issues/1419

来自詹姆斯·牛顿·金:

不,grpc-dotnet 中不会支持 .NET Framework 服务器。新的服务器实现基于 ASP.NET Core 构建,需要 HTTP/2 支持,而该支持仅在 .NET Core 3 或更高版本中提供。