问题描述
我在我的 .net core 3.1 项目中实现了 gRPC。虽然它在我的本地工作,但在服务器上不起作用。我尝试在我的项目中实现所有必要的东西来支持 gRPC。 在 appsettings 我使用 http2
"EndpointDefaults": {
"Protocols": "Http2;Http"
},
启动时:
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<IConfiguration>(Configuration);
services.UseOption<GrpcAddressesOptions>();
services.AddGrpc(o => { o.EnableDetailedErrors = true; });
}
public void Configure(IApplicationBuilder app,IWebHostEnvironment env,ILoggerFactory loggerFactory)
{
loggerFactory.AddManexLoggerProvider();
if (env.IsDevelopment())
app.UseDeveloperExceptionPage();
else if (env.IsProduction() || env.IsStaging()) app.UseManexExceptionHandler();
app.UseForwardedHeaders();
app.UseHsts();
app.UseRouting();
//TODO CheckEndpoint
app.UseEndpoints(endPoints => {
endPoints.MapGrpcService<GrpcCaller>();
});
}
但它在服务器中不起作用,我收到了这个例外:
Grpc.Core.RpcException: Status(StatusCode="Unimplemented",Detail="服务未实现。") 在
Grpc.Net.Client.Internal.HttpClientCallInvoker.BlockingUnaryCall[TRequest,TResponse](Method2 method,String host,CallOptions options,TRequest request) at Grpc.Core.Interceptors.InterceptingCallInvoker.<BlockingUnaryCall>b__3_0[TRequest,TResponse](TRequest req,ClientInterceptorContext
2 ctx) at
Grpc.Core.ClientBase.ClientBaseConfiguration.ClientBaseConfigurationInterceptor.BlockingUnaryCall[TRequest,TResponse](TRequest
请求,ClientInterceptorContext2 context,BlockingUnaryCallContinuation
2 继续)在
Grpc.Core.Interceptors.InterceptingCallInvoker.BlockingUnaryCall[TRequest,TResponse](方法`2
方法、字符串主机、CallOptions 选项、TRequest 请求)。 . . . .
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)