Logic 2 automation via C# and NET Framework 4.8

Hi, I am a new to Saleae, Logic 2 and GRPC. At work I received the task to integrate Logic 2 automation in our testing framework, but I am already getting really frustrated with it. NEED HELP !!!

So far, Logic 2 automation is distributed in a Python packages (not what I need).
I got the proto file from the Python package and added it to my C# solution using the nuget packages Google.Protobuf, Grpc.Tools and Grpc.Core (deprecated, but working).

After digging through some code and documentation I got the following snipped to run:

        var channel = new Channel("localhost:10430", ChannelCredentials.Insecure);
        var client = new Manager.ManagerClient(channel);

        var reply = client.GetAppInfo(new Dust.Saleae.GetAppInfoRequest());
        MessageBox.Show(reply.AppInfo.ApplicationVersion);

The problem is that Grpc.Core is deprecated in favor of the Grpc.Net.Client nuget package. And here is where all the trouble starts.

  1. Grpc.Net.Client is targeting NET.Core (we are using NET Framework 4.8)

  2. You can use Grpc.Net.Client with NET Framework, however you must set the HttpHandler to the
    WinHttpHandler available via a nuget package System.Net.Http.WinHttpHandler. This is owed to fact
    of missing HTTP/2 support of the HttpHandler in the NET Framework.

  3. The code snippet rewritten for Grpc.Net.Client now looks like that:

         var channel = GrpcChannel.ForAddress("https://localhost:10430", new GrpcChannelOptions
         {
             HttpHandler = new WinHttpHandler(),
         });
         var client = new DManager.ManagerClient(channel);
         var reply = client.GetAppInfo(new Dust.Saleae.GetAppInfoRequest());
         MessageBox.Show(reply.AppInfo.ApplicationVersion);
    

    However, running this code throws Grpc.Core.RpcException, HResult=0x80131500
    Message=Status(StatusCode=“Internal”, Detail=“Error starting gRPC call. HttpRequestException: An
    error occurred while sending the request. WinHttpException: Error 12175 calling
    WINHTTP_CALLBACK_STATUS_REQUEST_ERROR, ‘A security error occurred’.”,

  4. Ok, maybe my fault, because I specified “https://localhost:10430”. Trying to use
    http://localhost:10430” throws another exception Grpc.Core.RpcException, HResult=0x80131500
    Message=Status(StatusCode=“Internal”, Detail="Error starting gRPC call. HttpRequestException: An
    error occurred while sending the request. WinHttpException: Error 12152 calling
    WINHTTP_CALLBACK_STATUS_REQUEST_ERROR, ‘The server returned an invalid or unrecognized
    response’.

  5. Now it gets really bad. Digging through some more code including the low level python grpc stubs I
    see that the python stub defines the GetAppInfo method to use neither channel, nor call credentials
    with insecure set to false.

    @staticmethod
    def GetAppInfo(request,
    target,
    options=(),
    channel_credentials=None,
    call_credentials=None,
    insecure=False,
    compression=None,
    wait_for_ready=None,
    timeout=None,
    metadata=None):
    return grpc.experimental.unary_unary(request, target, ‘/saleae.automation.Manager/GetAppInfo’,
    saleae_dot_grpc_dot_saleae__pb2.GetAppInfoRequest.SerializeToString,
    saleae_dot_grpc_dot_saleae__pb2.GetAppInfoReply.FromString,
    options, channel_credentials,
    insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

  6. At this point I am ready to give up because I cannot figure out how to do this in the C# code,
    especially since the WinHttHandler requires TLS and any attempt to fiddle with the Credentials like
    setting them to ChannelCredentials.Insecure or SslCredentials.Insecure, etc… still produces the
    exception ‘The server returned an invalid or unrecognized response’

  7. To me it looks like the main issues are
    a) The Logic 2 automation is using http instead of https (which seems to be the recommended
    way for GRPC)
    b) the promoted Grpc.Net.Client is targeting NET.Core with limited NET Framework support.

ANY HELP WOULD BE GREATLY APPRECIATED

Even better, maybe provide another IPC mechanism to control Logic 2 from a local PC.
Even if I finally get it to run, I doubt that the solution will be very performant. With all the stuff regarding security etc… I would expect a call to take at least 30ms, probably with varying latency.

Sorry for the frustration with getting this working. I was in discussion with the software team last Friday about this (we saw your email come into our support inbox). It looks like you’ve provided more information on this forum post as well. Thanks for that.

We’ll let you know our recommendations / findings once we review this some more and have a grasp on what could be causing these issues for you.

@mschreier,

Sorry for the delay with this, and sorry for the trouble!

I’ve finished testing 3 different configurations:

  • .NET 7, using Grpc.Net.Client
  • .NET framework 4.8, using Grpc.Net.Client and both Grpc.Net.Client.Web and WinHttpHandler
  • .NET framework 4.8, using Grpc.Core

I’ve found the same findings as you. There is no way to get .NET Framework 4.8 to work with Grpc.Net.Client, presumably because our application does not support TLS.

NET 7 worked just fine with Grpc.Net.Client, and framework 4.8 worked just fine with Grpc.Core.

Unfortunately, that’s all we can offer at the moment. I recommend you continue to use Grpc.Core even after the maintenance period ends in May.

The only alternative would be for us to add support for TLS, not something that we’re currently planning to add.

Hello, after a long break, I’m back to working with the API based on C# with Visual Studio.
I’m able to successfully execute a “GetDevices(…”, but when I want to start a measurement I get an error in gRPC.
Hence the question, can you send me a working Visual Studio example project from your tests?
Regards, Jörg Schütte

@joerg.sch Sorry for the late reply! We had some folks out of office during the past week.

What specific gRPC error are you getting? I’ll check with the software team when I meet with them next week if we have any examples we can immediately share with you.