예제 #1
0
        static async Task Main(string[] args)
        {
            AppContext.SetSwitch(
                "System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport",
                true);

            var handler = new HttpClientHandler();

            handler.ServerCertificateCustomValidationCallback = ((a, b, c, d) => true);

            /*
             * handler.ClientCertificates.Add(
             *  new System.Security.Cryptography.X509Certificates.X509Certificate2("D:/Projects/grpctests/Development/Certificates/grpctests.pfx", "welkom01")
             *  );
             */
            var httpClient = new HttpClient(handler);

            httpClient.BaseAddress = new Uri($"https://localhost:{Port}");
            var client = GrpcClient.Create <F****r.FuckerClient>(httpClient);

            //var client = GrpcClient.Create<F****r.FuckerClient>(httpClient);
            var reply = await client.SayHelloAsync(
                new HelloRequest { Name = "GreeterClient" });

            Console.WriteLine("Greeting: " + reply.Message);
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
예제 #2
0
        private static Task <DemoService.DemoServiceClient> GetClient()
        {
            // This disables HTTPS
            // https://github.com/aspnet/AspNetCore.Docs/issues/13120
            AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
            var httpClient = new HttpClient
            {
                BaseAddress = new Uri("http://localhost:5000")
            };

            var client = GrpcClient.Create <DemoService.DemoServiceClient>(httpClient);

            return(Task.FromResult(client));
        }
예제 #3
0
        static async Task Main()
        {
            AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);

            // don't @ me about HttpClient/Dispose
            using var http = new HttpClient { BaseAddress = new Uri("http://localhost:10042") };

            var calc = GrpcClient.Create <Calculator.CalculatorClient>(http);

            for (int i = 0; i < 5; i++)
            {
                using var ma = calc.MultiplyAsync(new MultiplyRequest { X = i, Y = i });
                var calcResult = await ma.ResponseAsync;
                Console.WriteLine(calcResult.Result);
            }

            var clock = GrpcClient.Create <TimeService.TimeServiceClient>(http);

            using var subResult = clock.Subscribe(new Empty());
            using var reader    = subResult.ResponseStream;
            while (await reader.MoveNext(default))