На стороне сервера я Я настраиваю Kestrel так:
Код: Выделить всё
private void CreateServer()
{
_server = Host.CreateDefaultBuilder()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseKestrel();
webBuilder.ConfigureKestrel(options =>
{
options.Listen(IPAddress.Any, _port, listenOptions =>
{
listenOptions.Protocols = HttpProtocols.Http2;
listenOptions.UseHttps();
});
});
webBuilder.ConfigureServices(services =>
{
services.AddCodeFirstGrpc(options =>
{
options.MaxReceiveMessageSize = int.MaxValue;
options.MaxSendMessageSize = int.MaxValue;
});
});
webBuilder.Configure((IApplicationBuilder app) =>
{
app.UseRouting();
app.UseEndpoints(endpoints => endpoints.MapGrpcService());
});
}).Build();
_server.RunAsync();
}
Код: Выделить всё
private IGrpcService CreateClient()
{
var channelOption = new GrpcChannelOptions
{
MaxReceiveMessageSize = int.MaxValue,
MaxSendMessageSize = int.MaxValue,
};
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
var address = $"https://{_host}:{_port}";
Channel = GrpcChannel.ForAddress(address, channelOption);
IGrpcService client = Channel.CreateGrpcService();
client.SayHello("TESTING123");
return client;
}
Код: Выделить всё
Grpc.Core.RpcException: Status(StatusCode="Internal", Detail="Error starting gRPC call. HttpRequestException: No connection could be made because the target machine actively refused it. (testmachine1:59) SocketException: No connection could be made because the target machine actively refused it.", DebugException="System.Net.Http.HttpRequestException: No connection could be made because the target machine actively refused it. (testmachine1:59)
Есть идеи, почему это может происходить? Буду признателен за любую помощь, поскольку я не уверен, что делаю неправильно.
Подробнее здесь: https://stackoverflow.com/questions/701 ... te-machine