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.
-
Grpc.Net.Client is targeting NET.Core (we are using NET Framework 4.8)
-
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. -
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’.”, -
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’. -
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) -
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’ -
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.