grpc / grpc-dotnet

gRPC for .NET
Apache License 2.0
4.19k stars 769 forks source link

.net core 8-based (Maui) Client Devices: GRPC v GRPC.Web? #2369

Closed dgerding closed 7 months ago

dgerding commented 9 months ago

If I have a .net 8 grpc service client project should|can I use that to call from any .net 8 client or are there still platform dependencies? I'm hoping to use .net 8 maui clients (the whole mix: ios, windows, android, macos) to connect to a GRPC.net azure service (yes, http 2) but don't want to waste the time if .net 8 maui grpc.net client project code library will still be limited by platform.

These are not web apps or js processes calling the grpc server, just a single .net core 8 client c# project for the devices. Didn't know if having all device clients on .net 8 core and using same grpc.net project will let me use grpc.net with maui clients.

If I don't need js-based access to my grpc.net web and the clients all are net 8, can I skip grpc-web (via aspnetcore) and just use grpc.net ?

Any guidance appreciated.

JamesNK commented 9 months ago

Information about supported environments is available here: https://learn.microsoft.com/en-us/aspnet/core/grpc/supported-platforms?view=aspnetcore-8.0

hasslemark commented 7 months ago

.NET 8 introduced the .NET Multi-platform App UI (MAUI) framework, which aims to provide a unified way of building cross-platform applications for iOS, Android, Windows, and macOS using .NET. When it comes to using GRPC IN .NET MAUI clients, there are a few considerations:

Platform Support: .NET MAUI supports multiple platforms, including iOS, Android, Windows, and macOS. Since .NET MAUI is built on top of .NET, it should be compatible with gRPC libraries.

gRPC Client Library: .NET has its own gRPC client library, which should be compatible with .NET MAUI applications. You can use the Grpc.Net.Client package to create gRPC clients in your .NET MAUI application.

Cross-Platform Compatibility: Since .NET MAUI aims to provide a unified development experience across platforms, you should be able to use the same gRPC client code across different platforms without much modification.

grpc-web vs. grpc-dotnet: grpc-web is primarily used for browser-based applications where gRPC communication needs to happen over HTTP/HTTPS. Since you're building .NET MAUI applications, which are native apps, you can directly use the grpc-dotnet library for gRPC communication without needing grpc-web.

In summary, you should be able to use a .NET 8 gRPC client project with .NET MAUI clients without significant platform dependencies, as long as you use the appropriate gRPC client libraries. You can skip grpc-web since you're not targeting browser-based applications. Just make sure to use the Grpc.Net.Client package for gRPC communication in your .NET MAUI application.