Skip to content

Instantly share code, notes, and snippets.

@ayende
Created March 13, 2019 08:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayende/7fbbb32219ee1d4860bb8f2e8b9d724b to your computer and use it in GitHub Desktop.
Save ayende/7fbbb32219ee1d4860bb8f2e8b9d724b to your computer and use it in GitHub Desktop.
// sample showing that we need a way to handle the server not responding to some of the request
// separately from the overall time of the request
var server = new TcpListener(IPAddress.Any, 888);
server.Start();
server.AcceptTcpClientAsync().ContinueWith(x =>
{
var s = x.Result.GetStream();
s.WriteByte((byte)'H');
while (true)
{
s.ReadByte();
}
});
var client = new HttpClient(new SocketsHttpHandler
{
ResponseDrainTimeout = TimeSpan.FromSeconds(1)
})
{
Timeout = TimeSpan.FromSeconds(15),
};
var a = client.GetAsync("http://127.0.0.1:888/test").Result;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment