using System.Diagnostics;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Net;
using System.Net.Sockets;
CancellationTokenSource cts = new CancellationTokenSource(TimeSpan.FromSeconds(10));
Socket sc = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
var timer = Stopwatch.StartNew();
try
{
//sc.Connect(new IPEndPoint(IPAddress.Parse("222.56.1.45"), 11112));
sc.ConnectAsync(new IPEndPoint(IPAddress.Parse("222.56.1.45"), 11112),cts.Token).GetAwaiter().GetResult();
}
catch (Exception exp)
{
Console.WriteLine(exp);
Console.WriteLine($"Socket Exception in {timer.ElapsedMilliseconds} milliseconds");
}finally
{
timer.Stop();
}
How to setup non secure http2 for gRPC grpc/grpc-dotnet#505
Using configuration file
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"Kestrel": {
"EndPoints": {
"EndpointDefaults": {
"Url": "http://0.0.0.0:5220",
"Protocols": "Http2"
}
},
"AllowedHosts": "*"
}
}
OR Using code
builder.WebHost.ConfigureKestrel(kServerOptions =>
{
kServerOptions.Listen(IPAddress.Any, 8081, listenOptions =>
{
listenOptions.Protocols = HttpProtocols.Http2;
});
});
From Linux , Windows Curl does not support http2 negotiating Use gitbash with curl to test
curl -v --http2-prior-knowledge http://192.168.1.3:8081/weatherforecast