Open victoriorinescu opened 4 years ago
are you sure that the error doesn't happen at GetPeople()
? I ask because I'm not sure it has actually started talking gRPC before then, which means it shouldn't be throwing an RpcException
. Fundamentally, there's two completely different things that could be at play here:
CreateGrpcService<T>
, orservice.GetPeople()
If the problem is "1", then it is probably a problem for me to fix; if the problem is "2", then it is probably a problem for JamesNK over in grpc/grpc-dotnet
. So let's see if we can narrow it down! We can avoid "1" completely by using the non-emit API (please verify that this works on Windows before trying it on Xamarin):
var nonGeneric = channel.CreateGrpcService(typeof(IMyService));
var method = typeof(IMyService).GetMethod(nameof(IMyService.GetPeople));
#pragma warning disable CS0618 // hack around Empty marked [Obsolete]
var people = nonGeneric.BlockingUnary<Empty, People>(Empty.Instance, method);
#pragma warning restore CS0618
(where People
is whatever GetPeople()
returns; I can't see that in the example)
Let me know!
also: watch out for any HTTP inspection tools that might be running, such as Fiddler. They totally break gRPC.
doing some reading, it sounds like Xamarin gRPC support is a bit... wobbly right now, and that it is being targeted for .NET 5 timescales (later this year)
It was on people = service.GetPeople(); the debuger was shown the wrong line.
I have tried your code and also the error is on call:
var people = nonGeneric.BlockingUnary<Empty, IEnumerable<Person>>(Empty.Instance, method);
on xamarin: Grpc.Core.RpcException: 'Status(StatusCode=Internal, Detail="Error starting gRPC call. HttpRequestException: An error occurred while sending the request. IOException: The server returned an invalid or unrecognized response.")'
Edit:
on windows:
Actually on windows is working.
I put the wrong return type (Person instead of IEnumerable<Person>
).
k, the first thing to do is (rummages for antipodean summoning kit...) @JamesNK - any idea what the state of gRPC and Xamarin is?
I asked the Xamarin team a number of times whether they support HTTP/2 and they never confirmed it did.
If you want to use gRPC with a Xamarin client I recommend using gRPC-Web.
Thanks.
I ended up using asp.net core with controllers.
On Wed, Jul 8, 2020 at 11:15 PM James Newton-King notifications@github.com wrote:
I asked the Xamarin team a number of times whether they support HTTP/2 and they never confirmed it did.
If you want to use gRPC with a Xamarin client I recommend using gRPC-Web.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/protobuf-net/protobuf-net.Grpc/issues/112#issuecomment-655732905, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQBN2HJCWDKLZ5HUVAL7KJLR2THVZANCNFSM4OULURMQ .
Is there any way use Xamarin.Forms gRPC-Web with code first proto buf?
Does it work with "not code first" (meaning: contract first)? If so: it should work fine with code first. If it doesn't work with "contract first", then the transport itself is probably broken, and I can't fix that. If the transport works: "code first" should probably work.
My bad. I used http2 port. Even i could use http2 with Xamarin using original gRPC C# implementation, but joy of using code first stops it. Waiting for MAUI
Same problem here with Grpc Web.
The same code that works on windows does not work with Android (Xamarin)
`
`
The same thing happens if I use a secured connection.
On
service = channel.CreateGrpcService<IMyService>();
I get:Grpc.Core.RpcException: 'Status(StatusCode=Internal, Detail="Error starting gRPC call. HttpRequestException: An error occurred while sending the request. IOException: The server returned an invalid or unrecognized response.")'