dotnet-sdk
dotnet-sdk copied to clipboard
GRPC Exception - unable to connect to socket
Hi all,
Firstly thank you for a fabulous project and all your hard work.
I am really struggling with the GRPC example and indeed any GRPC over c# using Dapr.
I have added dapr/d to the security whitelist and am sure that this is not Windows firewall related. I hope!
Dapr.Client.InvocationException
HResult=0x80131500
Message=An exception occurred while invoking method: 'deposit' on app-id: 'grpcsample'
Source=Dapr.Client
StackTrace:
at Dapr.Client.DaprClientGrpc.<InvokeMethodGrpcAsync>d__312.MoveNext() in C:\Users\fig\Downloads\dotnet-sdk-master\src\Dapr.Client\DaprClientGrpc.cs:line 513 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()
at Samples.Client.InvokeServiceGrpcExample.<RunAsync>d__2.MoveNext() in C:\Users\fig\Downloads\dotnet-sdk-master\examples\Client\ServiceInvocation\InvokeServiceGrpcExample.cs:line 25
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Samples.Client.Program.<Main>d__1.MoveNext() in C:\Users\fig\Downloads\dotnet-sdk-master\examples\Client\ServiceInvocation\Program.cs:line 28
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Samples.Client.Program.<Main>(String[] args)
Inner Exception 1:
RpcException: Status(StatusCode="Internal", 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.
---> System.Net.Sockets.SocketException (10061): No connection could be made because the target machine actively refused it.
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean allowHttp2, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.GetHttp2ConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at Grpc.Net.Client.Internal.GrpcCall2.RunCall(HttpRequestMessage request, Nullable1 timeout)")
I would really appreciate any thoughts or suggestions please.
Many thanks
Fig
@lefig - how are you launching the application? Is the code somewhere public we can see?
Thank you @rynowak
So I follow instructions for the GRPC example contained within this repository.
I launch first the server application GRPCServiceSample.
But then when I start the client application, the exception fails arises here:
namespace Samples.Client { public class InvokeServiceGrpcExample : Example { public override string DisplayName => "Invoking a gRPC service with gRPC semantics and Protobuf with DaprClient";
// Note: the data types used in this sample are generated from data.proto in GrpcServiceSample
public override async Task RunAsync(CancellationToken cancellationToken)
{
using var client = new DaprClientBuilder().Build();
Console.WriteLine("Invoking grpc deposit");
var deposit = new GrpcServiceSample.Generated.Transaction() { Id = "17", Amount = 99 };
var account = await client.InvokeMethodGrpcAsync<GrpcServiceSample.Generated.Transaction, Account>("grpcsample", "deposit", deposit, .......................
Just to double check, Are you running the dapr sidecar? Or how are you launching the application?