runtime: `HttpRequestException`: Destination is too short. (Parameter 'destination')
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
While using YARP with HTTP3 enabled via an HttpTransformer
the request fails with a System.ArgumentException: Destination is too short. (Parameter 'destination')
.
Note that in this particular request, it was supposed to download the _framework/blazor.webassembly.js
and a couple of CSS files were successfully downloaded before:
I have only encountered this error while downloading this particular file if HttpRequestMessage.Version
is set to 3.0
.
Expected Behavior
Expected the request to complete successfully as it does for most cases, not once did it succeed for this script however.
Steps To Reproduce
- Create a basic YARP project, enable HTTP3 and set as default version for proxy-to-server communication.
public class Http3ProxyRequestTransformer : HttpTransformer
{
public override async ValueTask TransformRequestAsync(
HttpContext httpContext,
HttpRequestMessage proxyRequest,
string destinationPrefix)
{
await base.TransformRequestAsync(httpContext, proxyRequest, destinationPrefix);
// Configures all requests messages to use HTTP3
proxyRequest.Version = new Version(3, 0);
proxyRequest.VersionPolicy = HttpVersionPolicy.RequestVersionOrLower;
}
}
- Create a Blazor application and enable HTTP3 using
ConfigureKestrel
and a self-signed certificate:
webBuilder.ConfigureKestrel(serverOptions =>
{
serverOptions.ConfigureHttpsDefaults(httpsOptions =>
{
httpsOptions.ServerCertificateSelector = (_, name) =>
{
return name is not null
? CertificateLoader.LoadFromStoreCert(
"dev.localhost",
"My",
StoreLocation.CurrentUser,
false)
: null;
};
});
serverOptions.ListenAnyIP(5001, listenOptions =>
{
listenOptions.UseHttps();
listenOptions.Protocols = HttpProtocols.Http1AndHttp2AndHttp3;
});
});
- Forward all requests to the Blazor application:
var httpClient = new HttpMessageInvoker(new SocketsHttpHandler
{
UseProxy = false,
AllowAutoRedirect = false,
AutomaticDecompression = DecompressionMethods.None,
UseCookies = false
});
var requestConfig = new ForwarderRequestConfig
{
ActivityTimeout = TimeSpan.FromSeconds(100)
};
app.UseEndpoints(endpoints =>
{
endpoints.Map("/{**catch-all}", async httpContext =>
{
ForwarderError error = httpContext.Request.Host.ToString().Split('.') switch
{
[...]
_ => await forwarder.SendAsync(
httpContext,
Intranet,
httpClient,
requestConfig,
new Http3ProxyRequestTransformer())
};
});
});
Exceptions (if any)
info: Yarp.ReverseProxy.Forwarder.HttpForwarder[48]
Request: An error was encountered before receiving a response.
System.Net.Http.HttpRequestException: An error occurred while sending the request.
---> System.ArgumentException: Destination is too short. (Parameter 'destination')
at System.Net.Http.QPack.QPackDecoder.DecodeInternal(ReadOnlySpan`1 data, IHttpStreamHeadersHandler handler)
at System.Net.Http.Http3RequestStream.ReadHeadersAsync(Int64 headersLength, CancellationToken cancellationToken)
at System.Net.Http.Http3RequestStream.ReadResponseAsync(CancellationToken cancellationToken)
at System.Net.Http.Http3RequestStream.SendAsync(CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.Http3RequestStream.SendAsync(CancellationToken cancellationToken)
at System.Net.Http.Http3RequestStream.SendAsync(CancellationToken cancellationToken)
at System.Net.Http.Http3Connection.SendAsync(HttpRequestMessage request, Int64 queueStartingTimestamp, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.TrySendUsingHttp3Async(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at Yarp.ReverseProxy.Forwarder.HttpForwarder.SendAsync(HttpContext context, String destinationPrefix, HttpMessageInvoker httpClient, ForwarderRequestConfig requestConfig, HttpTransformer transformer)
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
Executed endpoint '/{**catch-all}'
fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HMM89CJQ7T8E", Request id "0HMM89CJQ7T8E:00000015": An unhandled exception was thrown by the application.
System.Net.Http.HttpRequestException: An error occurred while sending the request.
---> System.ArgumentException: Destination is too short. (Parameter 'destination')
at System.Net.Http.QPack.QPackDecoder.DecodeInternal(ReadOnlySpan`1 data, IHttpStreamHeadersHandler handler)
at System.Net.Http.Http3RequestStream.ReadHeadersAsync(Int64 headersLength, CancellationToken cancellationToken)
at System.Net.Http.Http3RequestStream.ReadResponseAsync(CancellationToken cancellationToken)
at System.Net.Http.Http3RequestStream.SendAsync(CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at Intervip.ReverseProxy.Startup.<>c__DisplayClass10_0.<<Configure>b__1>d.MoveNext() in C:\Users\bruno\source\repos\Intervip\reverse-proxy\Startup.cs:line 90
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Watch.BrowserRefresh.BrowserRefreshMiddleware.InvokeAsync(HttpContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished HTTP/2 GET https://dev.localhost/_framework/blazor.webassembly.js - - - 500 0 - 70.8280ms
.NET Version
7.0.100
Anything else?
PS C:\Users\bruno> dotnet --info
.NET SDK:
Version: 7.0.100
Commit: e12b7af219
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22000
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\7.0.100\
Host:
Version: 7.0.0
Architecture: x64
Commit: d099f075e4
.NET SDKs installed:
6.0.403 [C:\Program Files\dotnet\sdk]
7.0.100-rc.1.22431.12 [C:\Program Files\dotnet\sdk]
7.0.100-rc.2.22477.23 [C:\Program Files\dotnet\sdk]
7.0.100 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.0-rc.1.22427.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.0-rc.2.22476.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.0-rc.1.22426.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.0-rc.2.22472.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.0-rc.1.22427.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.0-rc.2.22472.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
arm64 [C:\Program Files\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\arm64\InstallLocation]
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
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (14 by maintainers)
@BrunoBlanes please don’t apologize, this is great investigation. You gave us stable repro and even dived into investigating this, that will help us a lot! Thank you!
It very likely depends on actual value and sequence. If the flow or headers are different you may not trigger it. You may also try to stop through in Debugger and check the
DecodeInternal
. At least in VS it should fetch correct sources for you automatically.Triage: Looks like
QPackDecoder
error where we attempt to copy to smaller buffer than necessary. We should fix this for 8.0.It would be nice to get an isolated repro though. I assume this could be reproduced without reverse proxy, blazor app etc.