dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.26k stars 4.73k forks source link

Quic support in .NET 6 preview #54338

Closed bentoi closed 3 years ago

bentoi commented 3 years ago

Description

I tried a sample program to create a Quic connection with .NET 6 preview 4. It fails on both macOS and Windows with a NullReferenceException:

Unhandled exception. System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an object.)
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Net.Quic.Implementations.MsQuic.Internal.SafeMsQuicConfigurationHandle.Create(QuicOptions options, QUIC_CREDENTIAL_FLAGS flags, X509Certificate certificate, List`1 alpnProtocols) in System.Net.Quic.dll:token 0x60001d3+0x127
   at System.Net.Quic.Implementations.MsQuic.Internal.SafeMsQuicConfigurationHandle.Create(QuicListenerOptions options) in System.Net.Quic.dll:token 0x60001d2+0x0
   at System.Net.Quic.Implementations.MsQuic.MsQuicListener.State..ctor(QuicListenerOptions options) in System.Net.Quic.dll:token 0x6000117+0x0
   at System.Net.Quic.Implementations.MsQuic.MsQuicListener..ctor(QuicListenerOptions options) in System.Net.Quic.dll:token 0x600010b+0x23
   at System.Net.Quic.Implementations.MsQuic.MsQuicImplementationProvider.CreateListener(QuicListenerOptions options) in System.Net.Quic.dll:token 0x6000108+0x0
   at System.Net.Quic.QuicListener..ctor(IPEndPoint listenEndPoint, SslServerAuthenticationOptions sslServerAuthenticationOptions) in System.Net.Quic.dll:token 0x600007c+0x0
   at quictestcase.Program.ServerAsync() in Program.cs:line 47

Configuration

macOS / Windows with .NET Core 6 preview 4

Other information

When building the program I get the following messages:

Program.cs(48,53): warning CA1416: This call site is reachable on all platforms. 'QuicListener.AcceptConnectionAsync(CancellationToken)' is only supported on: 'macOS/OSX', 'windows', 'linux'. [quictestcase.csproj]
ghost commented 3 years ago

Tagging subscribers to this area: @dotnet/ncl See info in area-owners.md if you want to be subscribed.

Issue Details
### Description I tried a sample program to create a Quic connection with .NET 6 preview 4. It fails on both macOS and Windows with a `NullReferenceException`: ``` Unhandled exception. System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an object.) ---> System.NullReferenceException: Object reference not set to an instance of an object. at System.Net.Quic.Implementations.MsQuic.Internal.SafeMsQuicConfigurationHandle.Create(QuicOptions options, QUIC_CREDENTIAL_FLAGS flags, X509Certificate certificate, List`1 alpnProtocols) in System.Net.Quic.dll:token 0x60001d3+0x127 at System.Net.Quic.Implementations.MsQuic.Internal.SafeMsQuicConfigurationHandle.Create(QuicListenerOptions options) in System.Net.Quic.dll:token 0x60001d2+0x0 at System.Net.Quic.Implementations.MsQuic.MsQuicListener.State..ctor(QuicListenerOptions options) in System.Net.Quic.dll:token 0x6000117+0x0 at System.Net.Quic.Implementations.MsQuic.MsQuicListener..ctor(QuicListenerOptions options) in System.Net.Quic.dll:token 0x600010b+0x23 at System.Net.Quic.Implementations.MsQuic.MsQuicImplementationProvider.CreateListener(QuicListenerOptions options) in System.Net.Quic.dll:token 0x6000108+0x0 at System.Net.Quic.QuicListener..ctor(IPEndPoint listenEndPoint, SslServerAuthenticationOptions sslServerAuthenticationOptions) in System.Net.Quic.dll:token 0x600007c+0x0 at quictestcase.Program.ServerAsync() in Program.cs:line 47 ``` ### Configuration macOS / Windows with .NET Core 6 preview 4 ### Other information When building the program I get the following messages: ``` /Users/benoit/Devel/GitHub/icerpc-csharp/quictestcase/Program.cs(48,53): warning CA1416: This call site is reachable on all platforms. 'QuicListener.AcceptConnectionAsync(CancellationToken)' is only supported on: 'macOS/OSX', 'windows', 'linux'. [/Users/benoit/Devel/GitHub/icerpc-csharp/quictestcase/quictestcase.csproj] ```
Author: bentoi
Assignees: -
Labels: `area-System.Net.Quic`, `untriaged`
Milestone: -
wfurt commented 3 years ago

How did you get msquic? It is not included in the runtime. Also example of you are trying to do would be helpful. On Windows, QUIC also depends on very recent Windows versions (like Insider Preview) and it will not run without proper Schannel support. Also there will not be QUIC api in .NET 6. The only one way how to console it will be via HTTP/3.

bentoi commented 3 years ago

I expected msquic to be included in the runtime. So this error is the result of msquic not being present? I'm trying to see if we can use Quic as a transport. Since the API is included in the .NET 6 preview documentation, I expected it would be useable without having to use HTTP/3.

wfurt commented 3 years ago

The story is complicated and you can try to build msquic yourself from https://github.com/microsoft/msquic/blob/main/docs/BUILD.md

QUIC API will not be public when 6.0 - ships as we don't have confidence we can make it 1st class citizen. It is still on TODO list and it will come come in some later release.

karelz commented 3 years ago

We plan to remove it from public API surface as part of .NET 6 Preview 7. We will bring it back after we ship/fork for .NET 7.

See #54534