I'm trying to remove GRPC.Core library before it's deprecated . I used Grpc.Server with custom port but now after using service.AddGrpc(), I can't set the port. My app uses both iis and grpc with net core 3.1. this is from my launchSettings:
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:53591",
"sslPort": 44314
}
},
this is the old code:
var grpcServer = new Server
{
Services =
{
},
Ports = { new ServerPort(_settings.GrpcServerHost, 50052, ServerCredentials.Insecure) },
RequestCallTokensPerCompletionQueue = 32768
};
and this is the new code from startup: //Grpc
services.AddGrpc(options =>
{
options.EnableDetailedErrors = true;
options.MaxReceiveMessageSize = 2 * 1024 * 1024; // 2 MB
options.MaxSendMessageSize = 5 * 1024 * 1024; // 5 MB
});
when I try to run my app I get :
Exception=Grpc.Core.RpcException: Status(StatusCode="Unavailable", Detail="Error starting gRPC call. HttpRequestException: No connection could be made because the target machine actively refused it. 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.
I also tried to add the url with UseUrls , in addition to the url for iis but it's not working -
return WebHost.CreateDefaultBuilder(args)
.UseUrls("http://*:53591", "http://*:50052")