This repository was archived by the owner on Dec 18, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 515
This repository was archived by the owner on Dec 18, 2018. It is now read-only.
Connection is not closed gracefully if client disconnected just before Dispose #1648
Copy link
Copy link
Closed
Description
Repro:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging;
namespace WebApplication2
{
public class Program : IObserver<DiagnosticListener>, IObserver<KeyValuePair<string, object>>
{
public static void Main(string[] args)
{
new Program().MainImpl(args);
}
public void MainImpl(string[] args)
{
DiagnosticListener.AllListeners.Subscribe(this);
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.UseApplicationInsights()
.ConfigureLogging(f=>f.AddConsole(LogLevel.Debug))
.Build();
host.Start();
Task t;
using (var httpClient = new HttpClient())
{
t = httpClient.GetAsync("http://localhost:5000//")
.ContinueWith(task => { Console.WriteLine("Request done"); });
t.Wait();
}
Console.WriteLine("Before Dispose");
host.Dispose();
Console.WriteLine("After Dispose");
Console.ReadLine();
}
public void OnCompleted()
{
}
public void OnError(Exception error)
{
}
public void OnNext(KeyValuePair<string, object> value)
{
if (value.Key == "Microsoft.AspNetCore.Hosting.EndRequest")
{
Console.WriteLine(value.Key);
Thread.Sleep(3000);
Console.WriteLine("After Microsoft.AspNetCore.Hosting.EndRequest");
}
}
public void OnNext(DiagnosticListener value)
{
value.Subscribe(this);
}
}
}
After Microsoft.AspNetCore.Hosting.EndRequest is printed after After Dispose
Reactions are currently unavailable