简体   繁体   English

Grpc.Core.RpcException: Status(StatusCode="Unavailable", Detail="Error starting gRPC call. HttpRequestException: Connection timed out SocketEx

[英]Grpc.Core.RpcException: Status(StatusCode=“Unavailable”, Detail="Error starting gRPC call. HttpRequestException: Connection timed out SocketEx

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.我正在尝试使用 xamarin vs2019 实现 GRPC 客户端,以下是我的解决方案资源管理器,我有 vs2019 模板生成服务和 xamarin 应用程序用于 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如果使用带有本地主机的控制台应用程序调试它,它可以工作,但是在 android 设备上我无法访问该服务并获得以下异常

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:\Users\yasarm\source\repos\App1\App1\App1\obj\Debug\netstandard2.1\Protos\GreetGrpc.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:\Users\yasarm\source\repos\App1\App1\App1\obj\Debug\netstandard2.1\Protos\GreetGrpc.cs:97   at App1.MainPage.Button_Clicked (System.Object sender, System.EventArgs e) [0x00017] in C:\Users\yasarm\source\repos\App1\App1\App1\MainPage.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.任何想法(源链接)在调试和运行时如何访问设备和模拟器上的 grpc 服务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM