TransWikia.com

My gRPC-Test Project just work on localhost

Stack Overflow Asked by blindmeis on January 2, 2021

i have the following problem.

I created a gRpc Server(Console App .Net 4.7.2 – i cant do Net Core on Server Side because of Crystal Reports 🙁) and a Client(WPF App .Net Core 3.1) and i can run it as long as Server and Client are on my machine (Windows 10). As far es i take my Server to another machine (windows Server 2016), it does not work anymore.

this is the RPC Exception:

Status(StatusCode="Unavailable", Detail="failed to connect to all
addresses",
DebugException="Grpc.Core.Internal.CoreErrorDetailException:
{"created":"@1595508082.170000000","description":"Failed to pick
subchannel","file":"T:srcgithubgrpcworkspace_csharp_ext_windows_x64srccoreextfiltersclient_channelclient_channel.cc","file_line":3948,"referenced_errors":[{"created":"@1595508082.170000000","description":"failed
to connect to all
addresses","file":"T:srcgithubgrpcworkspace_csharp_ext_windows_x64srccoreextfiltersclient_channellb_policypick_firstpick_first.cc","file_line":394,"grpc_status":14}]}")

i tried all variations. Here is my lastcode that works on localhost:

Server:

static void Main(string[] args)
    {
        var cacert = File.ReadAllText(@"root.crt");
        var servercert = File.ReadAllText(@"server.crt");
        var serverkey = File.ReadAllText(@"server.key");
        var keypair = new KeyCertificatePair(servercert, serverkey);
        var sslCredentials = new SslServerCredentials(new List<KeyCertificatePair>() { keypair }, cacert, false);

        // Build a server
        var server = new Server
        {
            Services = { ReportService.BindService(new KKarteReportService()) },
            Ports = { new ServerPort(Host, Port, sslCredentials) }
        };


        // Start server
        server.Start();

        Console.WriteLine("KKarteReport Server listening on port " + Port);
        Console.WriteLine("Press any key to stop the server...");
        Console.ReadKey();

        server.ShutdownAsync().Wait();
    }

Client

var cacert = File.ReadAllText(@"root.crt");
var clientcert = File.ReadAllText(@"client.crt");
var clientkey = File.ReadAllText(@"client.key");
var ssl = new SslCredentials(cacert, new KeyCertificatePair(clientcert, clientkey));
           
 var options = new List<ChannelOption> { new ChannelOption(ChannelOptions.SslTargetNameOverride, "MyServerHost") }; 
 var channel = new Channel("12.20.18.11", 5001, ssl, options);
 //var channel = new Channel("localhost", 5001, ssl, options);
 //var channel = new Channel(url, ChannelCredentials.Insecure);
 var client = new ReportService.ReportServiceClient(channel);

  using var streamingCall = client.CreateAusschreibung(request);

  await using var ms = new MemoryStream();

  while (await streamingCall.ResponseStream.MoveNext())
  {
        ms.Write(streamingCall.ResponseStream.Current.FileChunk.ToByteArray());
  }

What do i miss?

One Answer

What does the ‘Host‘ variable contain on the server side? The issue might be a incorrect address binding, which prevents the service from being reachable from IP addresses other than localhost (127.0.0.1). Try entering 0.0.0.0 there.

Answered by CoffeeCodeConverterImpl on January 2, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP