37 lines
915 B
C#
37 lines
915 B
C#
#!/usr/bin/env dotnet-script
|
|
#r "nuget: Grpc.Net.Client, 2.70.0"
|
|
#r "nuget: Google.Protobuf, 3.28.3"
|
|
#r "nuget: Grpc.Tools, 2.70.0"
|
|
|
|
using Grpc.Net.Client;
|
|
using Grpc.Core;
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
|
|
// We'll use reflection/dynamic to call the gRPC service
|
|
// This is a simple HTTP/2 test
|
|
|
|
var handler = new HttpClientHandler
|
|
{
|
|
ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
|
|
};
|
|
|
|
using var channel = GrpcChannel.ForAddress("http://localhost:5000", new GrpcChannelOptions
|
|
{
|
|
HttpHandler = handler
|
|
});
|
|
|
|
Console.WriteLine("Connected to gRPC server at http://localhost:5000");
|
|
Console.WriteLine("Channel state: " + channel.State);
|
|
|
|
// Test basic connectivity
|
|
try
|
|
{
|
|
await channel.ConnectAsync();
|
|
Console.WriteLine("Successfully connected!");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine($"Connection failed: {ex.Message}");
|
|
}
|