SaturnFramework / Saturn

Opinionated, web development framework for F# which implements the server-side, functional MVC pattern
https://saturnframework.org
MIT License
708 stars 108 forks source link

cannot get grpc extension to work in own project #204

Closed dgrimmin closed 4 years ago

dgrimmin commented 4 years ago

Let me start by saying the grpc extension is a really valuable addition to the Saturn framework, which is itself a pleasure to work with.

I get the grpc sample to work when I clone the gitrepo. It even nicely supports seq(float) that I require. It is so cool you only need to annotate the shared types to get grpc to work.

However, when I want to incorporate the saturn grpc extension in my project I get an error:

"[...]Application startup exception: System.MissingMethodException: Method not found: 'Microsoft.AspNetCore.Builder.IEndpointConventionBuilder Microsoft.AspNetCore.Builder.GrpcEndpointRouteBuilderExtensions.MapGrpcService(Microsoft.AspNetCore.Routing.IEndpointRouteBuilder)[...]"

Which I recon is a versioning thing according to https://github.com/grpc/grpc-dotnet/issues/246 .

This happens when I take the grpc example content and I reference Saturn and Saturn.Extensions.grpc. All is well according to intellisense (datatype-wise), but during runtime I get the above crash.

Any suggestions on how to manage the (transitive) package versions would be much appreciated. I am targetting netcoreapp3.0 as it seems to be a minimum requirement for grpc.

isaacabraham commented 4 years ago

Are you using NuGet or Paket? And yes GRPC is netcore3.x and above only.

dgrimmin commented 4 years ago

Paket, so I have been diving into the paket.lock file until my head was spinning. I am really hoping for some high levels settings to magically appear as a possible solution.

isaacabraham commented 4 years ago

Could you post the lock file (and / or a basic repro repository?). Thanks!

dgrimmin commented 4 years ago

Hi Isaac,

Thank you for wanting to help.

Here I created a minimal example https://github.com/dgrimmin/saturn-grpc-issue .

fake build dotnet .\src\gRpcSample\bin\Release\netcoreapp3.0\gRpcSample.dll

Application startup exception: System.MissingMethodException: Method not found: Microsoft.AspNetCore.Builder.IEndpointConventionBuilder Microsoft.AspNetCore.Builder.GrpcEndpointRouteBuilderExtensions.MapGrpcService(Microsoft.AspNetCore.Routing.IEndpointRouteBuilder). at Saturn.configureGrpcEndpoint@21-1.Invoke(IEndpointRouteBuilder endpoints) at Microsoft.AspNetCore.Builder.EndpointRoutingApplicationBuilderExtensions.UseEndpoints(IApplicationBuilder builder, Action1 configure) at Saturn.configureGrpcEndpoint@21.Invoke(IApplicationBuilder app)

I hope you are able to help.

isaacabraham commented 4 years ago

@dgrimmin I can repro here (I killed the lockfile and recreated just in case). Can you compare with this: https://github.com/protobuf-net/protobuf-net.Grpc/tree/master/examples/pb-net-grpc (which doesn't use saturn) - what's the difference? Perhaps convert the F# packages here with Paket and see what changes.

slang25 commented 4 years ago

I think referencing Giraffe 4 will fix this, related: https://github.com/SaturnFramework/Saturn/issues/201

isaacabraham commented 4 years ago

@slang25 could be. I'd love to better understand why it's happening nonetheless.

slang25 commented 4 years ago

Actually it's a little different to what I thought. It is expecting the return type on MapGrpcService to be different from what's in v2.23.2 : https://github.com/grpc/grpc-dotnet/blob/v2.23.2/src/Grpc.AspNetCore.Server/GrpcEndpointRouteBuilderExtensions.cs#L39

Saturn.Extensions.gRPC has been compiled against a lower version which is not binary compatible. This could be fixed by lower the Grpc.AspNetCore.Server in Saturn, or rebuilding with a newer minimum.

dgrimmin commented 4 years ago

Thank you for the insights. This is in line with the feeling I got when diving into the paket.lock files of the saturn repo and my own project.

I really hope this will provide the fix for the grpc extension. I’d love to start using it in production.

isaacabraham commented 4 years ago

@slang25 right. Do you know which version of the nuget package uses the "correct" (i.e. old!) version? That way at least @dgrimmin could be unblocked in the immediate term.

dgrimmin commented 4 years ago

@slang25, what is keeping you from answering Isaac’s? Anything I can do to help?

slang25 commented 4 years ago

@dgrimmin I tried but failed to figure out the right combination of package versions. I'll try again and let you know how I get on. What I first tried logically should have worked, so I'm missing something here.

dgrimmin commented 4 years ago

@slang25, your effort is much appreciated! If there are checks I can perform, please let me know.

Krzysztof-Cieslak commented 4 years ago

I think this should be solved with Giraffe 4.X and Saturn targeting netcoreapp3.1