Skip to content
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

QUIC fails to work after upgrading libmsquic to latest version #105788

Closed
ShreyasZare opened this issue Aug 1, 2024 · 16 comments
Closed

QUIC fails to work after upgrading libmsquic to latest version #105788

ShreyasZare opened this issue Aug 1, 2024 · 16 comments
Labels
area-System.Net.Quic tracking-external-issue The issue is caused by external problem (e.g. OS) - nothing we can do to fix it directly
Milestone

Comments

@ShreyasZare
Copy link

Description

The QuicConnection.IsSupported property returns false when libmsquic is upgraded to latest version 2.4.0 on Debian 12.6 (bookworm).

Reproduction Steps

Prepare a VM with Debian 12.6 (bookworm) and install libmsquic version 2.4.0 from Microsoft packages. Write a small console app to print to console response of QuicConnection.IsSupported property.

Expected behavior

The QuicConnection.IsSupported should return true when latest libmsquic is installed.

Actual behavior

The QuicConnection.IsSupported returns false when latest libmsquic is installed.

Regression?

Downgrading libmsquic to version 2.3.6 fixes this issue so seems like an issue only with version 2.4.0.

Known Workarounds

No response

Configuration

  • .NET 8.0.7 Runtime
  • Debian 12.6 (bookworm)
  • Observed on x64, not tested on other platforms.
  • Have received multiple feedback from different users so does not seem to be related to specific config.

Other information

No response

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Aug 1, 2024
Copy link
Contributor

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

@huoyaoyuan
Copy link
Member

Has msquic released a 2.4.0 version? The latest version on releases or tags page is still 2.3.6.

The msquic detection code is here:

if (OperatingSystem.IsWindows())
{
// Windows ships msquic in the assembly directory.
loaded = NativeLibrary.TryLoad(Interop.Libraries.MsQuic, typeof(MsQuicApi).Assembly, DllImportSearchPath.AssemblyDirectory, out msQuicHandle);
}
else
{
// Non-Windows relies on the package being installed on the system and may include the version in its name
loaded = NativeLibrary.TryLoad($"{Interop.Libraries.MsQuic}.{s_minMsQuicVersion.Major}", typeof(MsQuicApi).Assembly, null, out msQuicHandle) ||
NativeLibrary.TryLoad(Interop.Libraries.MsQuic, typeof(MsQuicApi).Assembly, null, out msQuicHandle);
}
if (!loaded)
{
// MsQuic library not loaded
NotSupportedReason = $"Unable to load MsQuic library version '{s_minMsQuicVersion.Major}'.";
if (NetEventSource.Log.IsEnabled())
{
NetEventSource.Info(null, NotSupportedReason);
}
return;
}
MsQuicOpenVersion = (delegate* unmanaged[Cdecl]<uint, QUIC_API_TABLE**, int>)NativeLibrary.GetExport(msQuicHandle, nameof(MsQuicOpenVersion));
MsQuicClose = (delegate* unmanaged[Cdecl]<QUIC_API_TABLE*, void>)NativeLibrary.GetExport(msQuicHandle, nameof(MsQuicClose));
if (!TryOpenMsQuic(out QUIC_API_TABLE* apiTable, out int openStatus))
{
// Too low version of the library (likely pre-2.0)
NotSupportedReason = $"MsQuicOpenVersion for version {s_minMsQuicVersion.Major} returned {openStatus} status code.";
if (NetEventSource.Log.IsEnabled())
{
NetEventSource.Info(null, NotSupportedReason);
}
return;
}
try
{
// Check version
uint paramSize;
int status;
paramSize = 4 * sizeof(uint);
uint* libVersion = stackalloc uint[4];
status = apiTable->GetParam(null, QUIC_PARAM_GLOBAL_LIBRARY_VERSION, &paramSize, libVersion);
if (StatusFailed(status))
{
if (NetEventSource.Log.IsEnabled())
{
NetEventSource.Error(null, $"Cannot retrieve {nameof(QUIC_PARAM_GLOBAL_LIBRARY_VERSION)} from MsQuic library: '{status}'.");
}
return;
}
Version = new Version((int)libVersion[0], (int)libVersion[1], (int)libVersion[2], (int)libVersion[3]);
paramSize = 64 * sizeof(sbyte);
sbyte* libGitHash = stackalloc sbyte[64];
status = apiTable->GetParam(null, QUIC_PARAM_GLOBAL_LIBRARY_GIT_HASH, &paramSize, libGitHash);
if (StatusFailed(status))
{
if (NetEventSource.Log.IsEnabled())
{
NetEventSource.Error(null, $"Cannot retrieve {nameof(QUIC_PARAM_GLOBAL_LIBRARY_GIT_HASH)} from MsQuic library: '{status}'.");
}
return;
}
string? gitHash = Marshal.PtrToStringUTF8((IntPtr)libGitHash);
MsQuicLibraryVersion = $"{Interop.Libraries.MsQuic} {Version} ({gitHash})";
if (Version < s_minMsQuicVersion)
{
NotSupportedReason = $"Incompatible MsQuic library version '{Version}', expecting higher than '{s_minMsQuicVersion}'.";
if (NetEventSource.Log.IsEnabled())
{
NetEventSource.Info(null, NotSupportedReason);
}
return;
}
if (NetEventSource.Log.IsEnabled())
{
NetEventSource.Info(null, $"Loaded MsQuic library '{MsQuicLibraryVersion}'.");
}
// Assume SChannel is being used on windows and query for the actual provider from the library if querying is supported
QUIC_TLS_PROVIDER provider = OperatingSystem.IsWindows() ? QUIC_TLS_PROVIDER.SCHANNEL : QUIC_TLS_PROVIDER.OPENSSL;
paramSize = sizeof(QUIC_TLS_PROVIDER);
apiTable->GetParam(null, QUIC_PARAM_GLOBAL_TLS_PROVIDER, &paramSize, &provider);
UsesSChannelBackend = provider == QUIC_TLS_PROVIDER.SCHANNEL;
if (UsesSChannelBackend)
{
// Implies windows platform, check TLS1.3 availability
if (!IsWindowsVersionSupported())
{
NotSupportedReason = $"Current Windows version ({Environment.OSVersion}) is not supported by QUIC. Minimal supported version is {s_minWindowsVersion}.";
if (NetEventSource.Log.IsEnabled())
{
NetEventSource.Info(null, NotSupportedReason);
}
return;
}
Tls13ServerMayBeDisabled = IsTls13Disabled(isServer: true);
Tls13ClientMayBeDisabled = IsTls13Disabled(isServer: false);
}
IsQuicSupported = true;

Basically it tries to load libmsquic.so.2 or libmsquic.so, then calls initialization. You can check network event source or manually replicate the steps to identify which step is failing.

@ShreyasZare
Copy link
Author

Has msquic released a 2.4.0 version? The latest version on releases or tags page is still 2.3.6.

The version 2.4.0 package is already available on official Microsoft packages: https://packages.microsoft.com/debian/12/prod/pool/main/libm/libmsquic/

@wfurt
Copy link
Member

wfurt commented Aug 1, 2024

can you try ldd libmsquic.so @ShreyasZare. I'm wondering if there is dependency problem....

@wfurt
Copy link
Member

wfurt commented Aug 1, 2024

cc: @nibanks

@ShreyasZare
Copy link
Author

can you try ldd libmsquic.so @ShreyasZare. I'm wondering if there is dependency problem....

Tried this command on multiple systems (Debian, Ubuntu) and the output is always:

ldd: ./libmsquic.so: No such file or directory

@ShreyasZare
Copy link
Author

Tested this on latest Raspberry Pi OS which is based on Debian 12 on Raspberry Pi 4B (arm64) with libmsquic version 2.4.0 works without any issues.

Also tested this on Ubuntu Server 24.04 LTS (x64) with libmsquic version 2.4.0 and it too has the same issue and QuicConnection.IsSupported returns false. Trying to make a QUIC connection throws following exception:

System.PlatformNotSupportedException: System.Net.Quic is not supported on this platform: Unable to load MsQuic library version '2'.
   at System.Net.Quic.QuicConnection.ConnectAsync(QuicClientConnectionOptions options, CancellationToken cancellationToken)

I have also posted this in a comment on this msquic issue.

Not sure if this is .NET specific issue or an issue with libmsquic itself.

@ladeak
Copy link
Contributor

ladeak commented Aug 1, 2024

I face the same issue with the prerelease .NET 9 version and ASP.NET Core on Linux Ubuntu 22.04:

System.InvalidOperationException: Unable to bind an HTTP/3 endpoint. This could be because QUIC has not been configured using UseQuic, or the platform doesn't support QUIC or HTTP/3.

Seems to work when I install v2.3.6 explicitly instead of 2.4.0

@ShreyasZare
Copy link
Author

I face the same issue with the prerelease .NET 9 version and ASP.NET Core on Linux Ubuntu 22.04:

Yes, Kestrel web server (ASP.NET Core) is also having same issue when attempting to enable HTTP/3 support.

@ManickaP ManickaP added this to the 9.0.0 milestone Aug 2, 2024
@ManickaP ManickaP added tracking-external-issue The issue is caused by external problem (e.g. OS) - nothing we can do to fix it directly and removed untriaged New issue has not been triaged by the area owner labels Aug 2, 2024
@ManickaP
Copy link
Member

ManickaP commented Aug 2, 2024

We're working with MsQuic team to fix this atm, the libmsquic 2.4 on packages.microsoft.com has an issue with dependencies. Workaround is to downgrade back to libmsquic 2.3.6. I'll let you know here when the package is fixed.

@liveans
Copy link
Member

liveans commented Aug 5, 2024

msquic 2.4.1 released (https://github.com/microsoft/msquic/releases/tag/v2.4.1) and packages are uploaded.
Problem is not reproducing anymore with new package.

@ShreyasZare
Copy link
Author

msquic 2.4.1 released (https://github.com/microsoft/msquic/releases/tag/v2.4.1) and packages are uploaded. Problem is not reproducing anymore with new package.

I tested this on Ubuntu Server 24.04 and the issue still persists with libmsquic version 2.4.1.

System.PlatformNotSupportedException: System.Net.Quic is not supported on this platform: Unable to load MsQuic library version '2'.
   at System.Net.Quic.QuicConnection.ConnectAsync(QuicClientConnectionOptions options, CancellationToken cancellationToken)

@liveans
Copy link
Member

liveans commented Aug 6, 2024

msquic 2.4.1 released (https://github.com/microsoft/msquic/releases/tag/v2.4.1) and packages are uploaded. Problem is not reproducing anymore with new package.

I tested this on Ubuntu Server 24.04 and the issue still persists with libmsquic version 2.4.1.

System.PlatformNotSupportedException: System.Net.Quic is not supported on this platform: Unable to load MsQuic library version '2'.
   at System.Net.Quic.QuicConnection.ConnectAsync(QuicClientConnectionOptions options, CancellationToken cancellationToken)

Yes, looks like this is still reproducing for Ubuntu 24.04

@liveans
Copy link
Member

liveans commented Aug 6, 2024

@ShreyasZare looks like some dependencies are still missing for Ubuntu 24.04, and we will be working with msquic team to fix it.

As a temporary workaround can you install libmsquic with these dependencies:

  • libxdp1
  • libnl-3-dev
  • libnl-route-3-dev

Command:

sudo apt install -y libmsquic libxdp1 libnl-3-dev libnl-route-3-dev

Can you verify this fixes your issue as a workaround?

@ShreyasZare
Copy link
Author

@liveans Thanks for the suggestion. I tried installing those dependencies on Ubuntu 24.04 (x64) and it worked. Thanks for that!

@liveans
Copy link
Member

liveans commented Aug 11, 2024

This issue should be fixed with msquic 2.4.3 release. If you can repro same issue again feel free to re-open/comment in this issue, so we can take a look.

@liveans liveans closed this as completed Aug 11, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Sep 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Net.Quic tracking-external-issue The issue is caused by external problem (e.g. OS) - nothing we can do to fix it directly
Projects
None yet
Development

No branches or pull requests

6 participants