-
Notifications
You must be signed in to change notification settings - Fork 889
Closed
Labels
Type: BugSomething isn't workingSomething isn't working
Description
Describe the bug
Using as a direct proxy. Having abundant UpgradeRequestCanceled
in the logs. Could be a symptom of misconfiguration or code flaw?
Log message:
2021-09-17 16:18:11.712 +03:00 [INF] "UpgradeRequestCanceled": Copying the upgraded request body was canceled.
System.Threading.Tasks.TaskCanceledException: The operation was canceled.
---> System.IO.IOException: Unable to read data from the transport connection: The I/O operation has been aborted because of either a thread exit or an application request..
---> System.Net.Sockets.SocketException (995): The I/O operation has been aborted because of either a thread exit or an application request.
--- End of inner exception stack trace ---
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.GetResult(Int16 token)
at System.Net.Http.HttpConnection.ReadAsync(Memory`1 destination)
at System.Net.Http.HttpConnection.RawConnectionStream.ReadAsync(Memory`1 buffer, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.HttpConnection.RawConnectionStream.ReadAsync(Memory`1 buffer, CancellationToken cancellationToken)
at Yarp.ReverseProxy.Forwarder.StreamCopier.CopyAsync(Boolean isRequest, Stream input, Stream output, IClock clock, CancellationToken cancellation)
To Reproduce
Code:
public void ConfigureServices(IServiceCollection services)
{
services.AddHttpProxyServices();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (!env.IsDevelopment())
{
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseEndpoints(builder =>
{
builder.MapHttpProxy("/{**catch-all}", "http://localhost:8080");
});
}
public static IEndpointConventionBuilder MapHttpProxy(this IEndpointRouteBuilder builder, string pattern, string destinationUri)
{
// Configure our own HttpMessageInvoker for outbound calls for proxy operations
var httpClient = new HttpMessageInvoker(new SocketsHttpHandler
{
UseProxy = false,
AllowAutoRedirect = false,
AutomaticDecompression = DecompressionMethods.None,
UseCookies = false,
});
return builder.Map(pattern, async httpContext =>
{
var httpForwarder = httpContext.RequestServices.GetRequiredService<IHttpForwarder>();
await httpForwarder.SendAsync(httpContext, destinationUri, httpClient);
});
}
public static class HttpProxyServiceCollectionEx
{
public static IServiceCollection AddHttpProxyServices(this IServiceCollection services)
{
services.AddHttpForwarder();
return services;
}
}
Further technical details
- .NET Core 3.1.14
- Yarp.ReverseProxy 1.0.0-preview.12.21451.3
- Windows 10 version 20H2
Metadata
Metadata
Assignees
Labels
Type: BugSomething isn't workingSomething isn't working