grpc .net core in docker Call Method failed Grpc.Core.RpcException: 'Status(StatusCode=Unavailable, Detail="Endpoint read failed")'

Created on 11 Apr 2017  路  1Comment  路  Source: grpc/grpc

I use the simplest Greeter Project , and then switch them into .net core1.1 project

Here is the Server Code
```C#
class GreeterImpl : Greeter.GreeterBase
{
// Server side handler of the SayHello RPC
public override Task SayHello(HelloRequest request, ServerCallContext context)
{
return Task.FromResult(new HelloReply { Message = "Hello " + request.Name });
}
}
class Program
{
const int Port = 50051;

public static void Main(string[] args)
{
  Server server = new Server
  {
    Services = { Greeter.BindService(new GreeterImpl()) },
    Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) }
  };
  server.Start();


  server.ShutdownTask.Wait();
}

}

Here is the Dockerfile
```docker
FROM microsoft/aspnetcore:1.1
ARG source
WORKDIR /app

COPY ${source:-obj/Docker/publish} .
ENTRYPOINT ["dotnet", "GreeterServer2.dll"]

Here is the build and run bash, they are success.

docker build -t ravenzz/hello .
docker run -p 50051:50051 ravenzz/hello:latest

But when I call it
I got the exception "Status(StatusCode=Unavailable, Detail="Endpoint read failed")"

   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Grpc.Core.Internal.AsyncCall`2.UnaryCall(TRequest msg)
   at Grpc.Core.DefaultCallInvoker.BlockingUnaryCall[TRequest,TResponse](Method`2 method, String host, CallOptions options, TRequest request)
   at Grpc.Core.Internal.InterceptingCallInvoker.BlockingUnaryCall[TRequest,TResponse](Method`2 method, String host, CallOptions options, TRequest request)
   at Helloworld.Greeter.GreeterClient.SayHello(HelloRequest request, CallOptions options) in D:\opensource\grpc\examples\csharp\helloworld\Greeter\HelloworldGrpc.cs:line 112
   at Helloworld.Greeter.GreeterClient.SayHello(HelloRequest request, Metadata headers, Nullable`1 deadline, CancellationToken cancellationToken) in D:\opensource\grpc\examples\csharp\helloworld\Greeter\HelloworldGrpc.cs:line 105
   at GreeterClient.Program.Main(String[] args) in D:\opensource\grpc\examples\csharp\helloworld\GreeterClient2\Program.cs:line 17

Any help is appreciated

Most helpful comment

Solved. I should listen on 0.0.0.0 not localhost

>All comments

Solved. I should listen on 0.0.0.0 not localhost

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aynaylan picture aynaylan  路  3Comments

qiuxin picture qiuxin  路  3Comments

juanjux picture juanjux  路  3Comments

GoldwinLeong picture GoldwinLeong  路  3Comments

jgeewax picture jgeewax  路  3Comments