Why does Xamarin Android fails to send GRPC/Http2 requests?

后端 未结 1 1508
暖寄归人
暖寄归人 2021-01-07 11:28

I\'m trying to run the xamarin forms sample from the Dot net conf 2019 keynote. I\'ve hosted the grpc service and a .net core console application can get data from it withou

相关标签:
1条回答
  • 2021-01-07 11:56

    I make it work your provided solution. Sorry i didnt cover exact details why your way didnt worked and this one worked. Also i couldn't test iOs version.

    Server. I changed only port version. I used release version. Btw I am not sure how successfully you could run Http1AndHttp2 and same ip and port. I had issues on personal project.

    Mobile Added Grpc.Core and Grpc.Core.Api nugets to both projects.

    I am creating channel differently. Your solution version

    var channel = GrpcChannel.ForAddress("123.123.123.123:123456");
    

    My version changed to

    var channel = new Channel("123.123.123.123:123456", ChannelCredentials.Insecure);
    

    This is not very secure version but could work for some time since http2 is already binary. Create and use secure way you need to sign certificate and use it in server and client. Good example is here

    Also i recommend to reuse channels since it is expensive to create new. Http2 is good at keeping multiple clients on one stream. You could recreate clients which is cheap operation.


    A little update from MS https://docs.microsoft.com/en-us/aspnet/core/grpc/client?view=aspnetcore-3.1

    Calling gRPC over HTTP/2 with Grpc.Net.Client is currently not supported on Xamarin. We are working to improve HTTP/2 support in a future Xamarin release. Grpc.Core and gRPC-Web are viable alternatives that work today.

    0 讨论(0)
提交回复
热议问题