grpc / grpc/grpc-dotnet

Unable to connect gRPC from Android <= 9 (using .NET MAUI) to Linux Azure WebApp API. Repository for reproduction attached.

Open
#2,126 9 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C#
Stars
4.5k
Forks
836
Avg merge
6d 3h
Merged PRs (30d)
7

Description

### What version of gRPC and what language are you using?
C# .NET 7
proto3
Visual Studio Version 17.5.5
Grpc.Net.Client 2.53.0
Grpc.Tools 2.54.0
Google.Protobuf 3.23.0

### What operating system (Linux, Windows,...) and version?
Server = Azure WebApp running on linux
Failing clients = Android 9 and older
Successful Clients = Android 10 and newer

### What runtime / compiler are you using (e.g. .NET Core SDK version `dotnet --info`)
.NET SDK:
Version: 7.0.203
Commit: 5b005c19f5

Runtime Environment:
OS Name: Windows
OS Version: 10.0.22621
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\7.0.203\

Host:
Version: 7.0.5
Architecture: x64
Commit: 8042d61b17

.NET SDKs installed:
6.0.311 [C:\Program Files\dotnet\sdk]
6.0.400-preview.22330.6 [C:\Program Files\dotnet\sdk]
7.0.100 [C:\Program Files\dotnet\sdk]
7.0.203 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
Not set

global.json file:
Not found

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download

### What did you do?
I have prepared a repository with a Visual Studio for you to test here: https://github.com/czmirek/maui_droid_linuxazapp_grpc_bug

- Create an Linux Azure WebApp for .NET 7
- Configure the web app to enable gRPC
- Add env variable **HTTP20_ONLY_PORT = 8585**
- Set **Http Version = 2.0**
- Set **Http 2.0 Proxy = On**
- Deply project *GrpcWebApi* on the WebApp.
- Get the webapp URL from Azure Portal and replace the string in `MainPage.xaml.cs`
- `const string testUrl = "https://YOURAPP.azurewebsites.net";`
- Download Android 10 emulator
- Run **MauiTest** in Android 10. You'll see the following screen:

image

- Push "Test HTTP/2". You'll get dialog with message "TEST". = HTTP/2 works.
- Push "Test gRPC". You'll get dialog with message "Hello TEST". = gRPC works
- Repeat the same for Android 9 or less
- Push "Test HTTP/2". You'll get dialog with message "TEST". = HTTP/2 works.
- Push "Test gRPC". You'll get the following exception.

**`Error starting gRPC call. HttpRequestException: Requesting HTTP version 2.0 with version policy RequestVersionOrHigher while unable to estabilish HTTP/2 connection.`**

### What did you expect to see?
For Android 9 or lower:
- Push "Test gRPC". You'll get dialog with message "Hello TEST". = gRPC works

### What did you see instead?
Exception is thrown.

**`Error starting gRPC call. HttpRequestException: Requesting HTTP version 2.0 with version policy RequestVersionOrHigher while unable to estabilish HTTP/2 connection.`**

### Anything else we should know about your project / environment?

- If you try it locally (after disabling HTTPS certificate checks) over HTTP then it works even with Android 9 and lower versions!
- This makes me suspicious of a bug related to TLS.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.