-
Notifications
You must be signed in to change notification settings - Fork 24.7k
Split gRPC supported platforms doc into hosting services and calling services sections #21689
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ed4f620
Improve gRPC supported platforms doc
JamesNK eafc9e6
Update
JamesNK 3ef55b1
Update
JamesNK 765f02d
Update
JamesNK 6737dd5
Merge branch 'main' into jamesnk/grpc-supported-platforms-v2
JamesNK d070d38
Update netstandard.md
JamesNK e23a06f
Update supported-platforms.md
JamesNK File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| --- | ||
| title: Use gRPC client with .NET Standard 2.0 | ||
| author: jamesnk | ||
| description: Learn how to use the .NET gRPC client in apps and libraries that support .NET Standard 2.0. | ||
| monikerRange: '>= aspnetcore-3.0' | ||
| ms.author: jamesnk | ||
| ms.date: 3/11/2021 | ||
| no-loc: [appsettings.json, "ASP.NET Core Identity", cookie, Cookie, Blazor, "Blazor Server", "Blazor WebAssembly", "Identity", "Let's Encrypt", Razor, SignalR] | ||
| uid: grpc/netstandard | ||
| --- | ||
| # Use gRPC client with .NET Standard 2.0 | ||
|
|
||
| By [James Newton-King](https://twitter.com/jamesnk) | ||
|
|
||
| This article discusses how to use the .NET gRPC client with .NET implementations that support [.NET Standard 2.0](/dotnet/standard/net-standard). | ||
|
|
||
| ## .NET implementations | ||
|
|
||
| The following .NET implementations (or later) support [Grpc.Net.Client](https://www.nuget.org/packages/Grpc.Net.Client/) but don't have full support for HTTP/2: | ||
|
|
||
| * .NET Core 2.1 | ||
| * .NET Framework 4.6.1 | ||
| * Mono 5.4 | ||
| * Xamarin.iOS 10.14 | ||
| * Xamarin.Android 8.0 | ||
| * Universal Windows Platform 10.0.16299 | ||
| * Unity 2018.1 | ||
|
|
||
| The .NET gRPC client can call services from these .NET implementations with some additional configuration. | ||
|
|
||
| ## HttpHandler configuration | ||
|
|
||
| An HTTP provider must be configured using `GrpcChannelOptions.HttpHandler`. If a handler isn't configured, an error is thrown: | ||
|
|
||
| > `System.PlatformNotSupportedException`: gRPC requires extra configuration to successfully make RPC calls on .NET implementations that don't have support for gRPC over HTTP/2. An HTTP provider must be specified using `GrpcChannelOptions.HttpHandler`. The configured HTTP provider must either support HTTP/2 or be configured to use gRPC-Web. | ||
|
|
||
| .NET implementations that don't support HTTP/2, such as UWP, Xamarin, and Unity, can use gRPC-Web as an alternative. | ||
|
|
||
| ```csharp | ||
| var channel = GrpcChannel.ForAddress("https://localhost:5001", new GrpcChannelOptions | ||
| { | ||
| HttpHandler = new GrpcWebHandler(new HttpClientHandler()) | ||
| }); | ||
|
|
||
| var client = new Greeter.GreeterClient(channel); | ||
| var response = await client.SayHelloAsync(new HelloRequest { Name = ".NET" }); | ||
| ``` | ||
|
|
||
| For more information, see [Configure gRPC-Web with the .NET gRPC client](xref:grpc/browser#configure-grpc-web-with-the-net-grpc-client). | ||
|
|
||
| ## .NET Framework | ||
|
|
||
| .NET Framework has limited support for gRPC over HTTP/2. To enable gRPC over HTTP/2 on .NET Framework, configure the channel to use <xref:System.Net.Http.WinHttpHandler>. | ||
|
|
||
| Requirements and restrictions to using `WinHttpHandler`: | ||
|
|
||
| * Windows 10 Build 19622 or later. | ||
| * A reference to the [System.Net.Http.WinHttpHandler](https://www.nuget.org/packages/System.Net.Http.WinHttpHandler/) NuGet package. | ||
| * Only unary and server streaming gRPC calls are supported. | ||
| * Only gRPC calls over TLS are supported. | ||
|
|
||
| ```csharp | ||
| var channel = GrpcChannel.ForAddress("https://localhost:5001", new GrpcChannelOptions | ||
| { | ||
| HttpHandler = new WinHttpHandler() | ||
| }); | ||
|
|
||
| var client = new Greeter.GreeterClient(channel); | ||
| var response = await client.SayHelloAsync(new HelloRequest { Name = ".NET" }); | ||
| ``` | ||
|
|
||
| > [!NOTE] | ||
| > .NET Framework support is in its early stages and requires using pre-release software. | ||
| > * Windows 10 Build 19622 or later is available as a [Windows Insiders](https://insider.windows.com/) build. | ||
| > * The required version of `System.Net.Http.WinHttpHandler` is not currently available on NuGet.org. The latest pre-release version is available on [this NuGet feed](https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json) should be used. | ||
|
|
||
| ## gRPC C# core-library | ||
|
|
||
| An alternative option for .NET Framework and Xamarin is to use [gRPC C# core-library](https://grpc.io/docs/languages/csharp/quickstart/) to make gRPC calls. It's a third party library that supports making gRPC calls over HTTP/2 on .NET Framework and Xamarin. gRPC C-core is not supported by Microsoft. | ||
|
|
||
| ## Additional resources | ||
|
|
||
| * <xref:grpc/client> | ||
| * <xref:grpc/browser> | ||
| * [gRPC C# core-library](https://grpc.io/docs/languages/csharp/quickstart/) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.