Skip to content

Instantly share code, notes, and snippets.

Avatar

Anton Firszov antonfirsov

View GitHub Profile
@antonfirsov
antonfirsov / ProtocolExceptions.MD
Last active Jun 9, 2022
Exposing HTTP/2 and HTTP/3 protocol error details from `SocketsHttpHandler`
View ProtocolExceptions.MD

Exposing HTTP/2 and HTTP/3 protocol error details from SocketsHttpHandler

This proposal builds on the decisions made in our QUIC Exceptions Design proposal.

Proposed design

  • Define a new exception type ProtocolException, and embed it as HttpRequestException.InnerException
  • Throw ProtocolException directly from HttpResponse content read streams
  • In case of HTTP/3, embed QuicException as ProtocolException.InnerException
View GCMemoryInfoMinimalRepro.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0;net5.0;netcoreapp3.1</TargetFrameworks>
</PropertyGroup>
</Project>
View _ExhaustTest.cs
public class _ExhaustTest : IDisposable
{
public const int ListenerCount = 1000;
public const int ConnectCount = 1024 * 20;
//public const int ConnectCount = 10;
private readonly ITestOutputHelper _output;
private Task[] _listenTasks = new Task[ListenerCount];
private Socket[] _listeners = new Socket[ListenerCount];
@antonfirsov
antonfirsov / Type1.txt
Created Mar 22, 2021
HTTP Stress failures
View Type1.txt
2021-03-18T15:01:04.4504783Z client_1 | System.Net.Http.HttpRequestException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (server:5001)
2021-03-18T15:01:04.4506315Z
2021-03-18T15:01:04.4508672Z client_1 | ---> System.Net.Sockets.SocketException (10060): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
2021-03-18T15:01:04.4509920Z
2021-03-18T15:01:04.4511533Z client_1 | at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken) in /_/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.Tasks.cs:line 1233
2021-03-18T15:01:04.4512995Z
2021-03-18T15:01:04.4514290Z client_1 | at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.
View Backend Utility Class.cs
public static void TransformImage(ImageEditModel imageEdit, MemoryStream destinationStream)
{
if (destinationStream == null)
{
throw new ArgumentNullException(nameof(destinationStream));
}
var sourceImage = Image.Load(imageEdit.SourceStream);
var blur = imageEdit.History.Where(h => h.Tool == ImageTool.Blur).FirstOrDefault();
View ColonTest.cs
using SixLabors.Fonts;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Drawing.Processing;
using System;
using SixLabors.ImageSharp.PixelFormats;
namespace ColonTest
{
class Program
View WinHttpSSLFailures.html
<html xmlns:tp="http://schemas.datacontract.org/2004/07/Microsoft.VisualStudio.TestPlatform.Extensions.HtmlLogger.ObjectModel" xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<body>
<h1>Test run details</h1>
<div class="summary">
<div class="block"><span>Total tests</span><div class="total-tests">1182</div><br></div>
<div class="block"><span>Passed : </span><span class="passedTests">1153</span><br><span>Failed : </span><span class="failedTests">9</span><br><span>Skipped : </span><span class="skippedTests">20</span><br></div>
<div class="block"><span>Pass percentage</span><div class="pass-percentage">97 %</div><br></div>
<div class="block"><span>Run duration</span><div class="test-run-time">43s 95ms</div><br></div><br></div>
<h2>Failed Results</h2>
View TrailingHeaders_RemoteServer_Test.cs
[ConditionalFact(nameof(OsSupportsWinHttpTrailingHeaders))]
public async Task Http2GetAsyncResponseHeadersReadOption_RemoteServer_TrailingHeaders_Available()
{
Uri address = new Uri("https://localhost:5001/trailers.ashx");
using (HttpClient client = CreateHttpClient())
{
Task<HttpResponseMessage> sendTask = client.GetAsync(address, HttpCompletionOption.ResponseHeadersRead);
HttpResponseMessage response = await sendTask;
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
View CreateHttpClientWithReusePort.cs
// The workaround is utilizing ConnectCallback, which is a .NET 5+ feature.
// For more info see:
// https://devblogs.microsoft.com/dotnet/net-5-new-networking-improvements/#socketshttphandler-extension-points
public HttpClient CreateHttpClientWithReusePort()
{
SocketsHttpHandler handler = new SocketsHttpHandler
{
ConnectCallback = ReusePortConnectAsync
};
return new HttpClient(handler);
View SocketTestHang-MAC.txt
Console log: 'System.Net.Sockets.Tests' from job 93f31455-92dc-4293-9906-96117cc681c8 workitem ce7ce536-f347-49cb-b6f2-f083b0982a70 (osx.1015.amd64.open) executed on machine dci-macpro-09.local
+ ./RunTests.sh --runtime-path /tmp/helix/working/993B086D/p
----- start Thu Jan 21 09:13:50 PST 2021 =============== To repro directly: =====================================================
pushd .
/tmp/helix/working/993B086D/p/dotnet exec --runtimeconfig System.Net.Sockets.Tests.runtimeconfig.json --depsfile System.Net.Sockets.Tests.deps.json xunit.console.dll System.Net.Sockets.Tests.dll -xml testResults.xml -nologo -nocolor -notrait category=IgnoreForCI -notrait category=OuterLoop -notrait category=failing
popd
===========================================================================================================
/private/tmp/helix/working/993B086D/w/B692097E/e /private/tmp/helix/working/993B086D/w/B692097E/e
Discovering: System.Net.Sockets.Tests (method display = ClassAndMethod, method display options = Non