I am trying to achive a GRPC client with xamarin vs2019 following is my solution-explorer i have vs2019 template generated service and an xamarin application for android. if debug it with console app with localhost it works, but on the android device i cannot reach the service and get the following exception
Grpc.Core.RpcException: Status(StatusCode="Unavailable", Detail="Error starting gRPC call. HttpRequestException: Connection timed out SocketException: Connection timed out", DebugException="System.Net.Http.HttpRequestException: Connection timed out ---> System.Net.Sockets.SocketException: Connection timed out at System.Net.Http.ConnectHelper.ConnectAsync (System.String host, System.Int32 port, System.Threading.CancellationToken cancellationToken) [0x000c8] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectHelper.cs:65 --- End of inner exception stack trace --- at System.Net.Http.ConnectHelper.ConnectAsync (System.String host, System.Int32 port, System.Threading.CancellationToken cancellationToken) [0x00180] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectHelper.cs:84 at System.Threading.Tasks.ValueTask`1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813 at System.Net.Http.HttpConnectionPool.CreateConnectionAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x000ea] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs:385 at System.Threading.Tasks.ValueTask`1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813 at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync (System.Threading.Tasks.ValueTask`1[TResult] creationTask) [0x000a2] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs:543 at System.Threading.Tasks.ValueTask`1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813 at System.Net.Http.HttpConnectionPool.SendWithRetryAsync (System.Net.Http.HttpRequestMessage request, System.Boolean doRequestAuth, System.Threading.CancellationToken cancellationToken) [0x0003f] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs:284 at System.Net.Http.RedirectHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00070] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/RedirectHandler.cs:32 at Grpc.Net.Client.Internal.GrpcCall`2[TRequest,TResponse].RunCall (System.Net.Http.HttpRequestMessage request, System.Nullable`1[T] timeout) [0x0020c] in /_/src/Grpc.Net.Client/Internal/GrpcCall.cs:452 ") at Grpc.Net.Client.Internal.HttpClientCallInvoker.BlockingUnaryCall[TRequest,TResponse] (Grpc.Core.Method`2[TRequest,TResponse] method, System.String host, Grpc.Core.CallOptions options, TRequest request) [0x0000b] in /_/src/Grpc.Net.Client/Internal/HttpClientCallInvoker.cs:118 at Grpc.Core.Interceptors.InterceptingCallInvoker.<BlockingUnaryCall>b__3_0[TRequest,TResponse] (TRequest req, Grpc.Core.Interceptors.ClientInterceptorContext`2[TRequest,TResponse] ctx) [0x00000] in /var/local/git/grpc/src/csharp/Grpc.Core.Api/Interceptors/InterceptingCallInvoker.cs:51 at Grpc.Core.ClientBase+ClientBaseConfiguration+ClientBaseConfigurationInterceptor.BlockingUnaryCall[TRequest,TResponse] (TRequest request, Grpc.Core.Interceptors.ClientInterceptorContext`2[TRequest,TResponse] context, Grpc.Core.Interceptors.Interceptor+BlockingUnaryCallContinuation`2[TRequest,TResponse] continuation) [0x00000] in /var/local/git/grpc/src/csharp/Grpc.Core.Api/ClientBase.cs:174 at Grpc.Core.Interceptors.InterceptingCallInvoker.BlockingUnaryCall[TRequest,TResponse] (Grpc.Core.Method`2[TRequest,TResponse] method, System.String host, Grpc.Core.CallOptions options, TRequest request) [0x00000] in /var/local/git/grpc/src/csharp/Grpc.Core.Api/Interceptors/InterceptingCallInvoker.cs:48 at GrpcService1.Greeter+GreeterClient.SayHello (GrpcService1.HelloRequest request, Grpc.Core.CallOptions options) [0x00001] in C:Usersyasarmsource
eposApp1App1App1objDebug
etstandard2.1ProtosGreetGrpc.cs:107 at GrpcService1.Greeter+GreeterClient.SayHello (GrpcService1.HelloRequest request, Grpc.Core.Metadata headers, System.Nullable`1[T] deadline, System.Threading.CancellationToken cancellationToken) [0x00001] in C:Usersyasarmsource
eposApp1App1App1objDebug
etstandard2.1ProtosGreetGrpc.cs:97 at App1.MainPage.Button_Clicked (System.Object sender, System.EventArgs e) [0x00017] in C:Usersyasarmsource
eposApp1App1App1MainPage.xaml.cs:25
Button click code
private async void Button_Clicked(object sender, EventArgs e)
{
try {
var client = new GreeterClient(GrpcChannel.ForAddress(new Uri("https://192.168.1.232:5001")));
var reply = await client.SayHelloAsync(new GrpcService1.HelloRequest() { Name = nametext.Text });
replytext.Text = reply.Message;
}
catch(Exception ex)
{
var b=ex.ToString();
}
}
any idea (source link) what how to access the grpc service on device and emulator while debuging and running.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…