Last active
August 14, 2019 23:10
-
-
Save mustakimali/bdc8d4f7034ac8e985e3143976e571de to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Net.Http; | |
using System.Threading.Tasks; | |
using Grpc.Net.Client; | |
using GrpcDotNetDemoPackage; | |
namespace Client | |
{ | |
class Program | |
{ | |
static async Task Main(string[] args) | |
{ | |
var client = await GetClient(); | |
var response = await client.SayHelloAsync(new HelloRequest | |
{ | |
Name = "Mustakim" | |
}); | |
Console.WriteLine(response.Hello); | |
} | |
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); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<TargetFramework>netcoreapp3.0</TargetFramework> | |
<OutputType>Exe</OutputType> | |
</PropertyGroup> | |
<ItemGroup> | |
<PackageReference Include="Grpc.Net.Client" Version="0.1.22-pre2" /> | |
</ItemGroup> | |
<ItemGroup> | |
<ProjectReference Include="..\Protos\Protos.csproj" /> | |
</ItemGroup> | |
</Project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment