I've created a DotNet Core 3.1 gRPC server.
Is it possible to user this server in a DotNet Frametwork 4.8 client?
I've referenced these packages:
- Google.Protobuf
- Grpc.Core
- Grpc.Core.Api
My test code looks like this:
using Grpc.Core;
using System;
using System.Windows.Forms;
namespace DotNetgRpcTest.ClientWinformC
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Channel channel = new Channel("127.0.0.1:50051", ChannelCredentials.Insecure);
var client = new Greeter.GreeterClient(channel);
String user = "John";
var reply = client.SayHello(new HelloRequest { Name = user });
Console.WriteLine("Greeting: " + reply.Message);
}
}
}
I've copied the greet.proto from the server...
But it can't find Greeter in the code above.
Is it at all poosible to do?
UPDATE.......
I managed to put the Protos in a .Net Standard 2.0 library with these nugets:
- Grpc
- Grpc.Core
- Grpc.Tools
Next problem...
When I run the apps, my .Net Frmawork 4.8 app gives me this error:
Grpc.Core.RpcException: 'Status(StatusCode=Unavailable, Detail="failed to connect to all addresses")'
From google I learned that this code in the server would fix it...
webBuilder.ConfigureKestrel(options =>
{
// This endpoint will use HTTP/2 and HTTPS on port 5001.
options.Listen(IPAddress.Any, 5001, listenOptions =>
{
listenOptions.Protocols = HttpProtocols.Http2;
});
});
Well it did - now my .Net Framework 4.8 app works .... but now my .Net Core client app gives me this error:
Grpc.Core.RpcException: 'Status(StatusCode=Internal, Detail="Error starting gRPC call: The SSL connection could not be established, see inner exception.")'