ni / grpc-labview

gRPC client and server support for LabVIEW
MIT License
90 stars 62 forks source link

Error when connecting LabVIEW gRPC client to C# server #374

Open suresh06-lv opened 3 months ago

suresh06-lv commented 3 months ago

Description Timeout error when trying to connect LabVIEW gRPC client to C# gRPC Server.
Encountered this problem when attempting to use the LabVIEW client to simulate TestStand operations by connecting to a C# server. This issue was first seen when trying to connect to the C# server provided in https://github.com/ni/grpc-teststand-api. I discovered that the problem persists even with a basic C# greeter gRPC service.

Steps to Reproduce

  1. Create a C# greeter service based on the tutorial from https://learn.microsoft.com/en-us/aspnet/core/tutorials/grpc/grpc-start?view=aspnetcore-8.0&tabs=visual-studio.
  2. Create a LabVIEW client using the proto file generated from step1.
  3. Build a sample gRPC client VI.
  4. Run the service.
  5. Connect LabVIEW greeter client using the address shown in the terminal and Run VI.

Expected Result Greeter response string concatenated with 'Hello' as prefix to client message input. "Hello " + Client Message

Actual Result image

Version LabVIEW - 2023 Q3

Images image

AB#2832543

j-medland commented 3 months ago

I don't think you want to specify the protocol in the server address just hostname:port

suresh06-lv commented 3 months ago

Thanks j-medland. That works for simple greeter service. But with the C# project for teststand services we're still seeing the error -1014 but with a different error message. image

jasonmreding commented 2 months ago

Double check there isn't an http proxy configured on your network. If there is one, you might need to bypass the proxy for your grpc server.

suresh06-lv commented 2 months ago

Hi Jason, Thanks for the comment.
Checked now and found that the proxy server is not configured already. So the previous attempts were also executed by bypassing the proxy server.

Franky-86 commented 2 months ago

If you‘re using https you need to provide the public part of a certificate (.crt). During creation of the C# project there was a popup that asked you to accept the user signed developer certificate. This certificate as a file should be used to create the client.

jasonmreding commented 1 month ago

FWIW, I have successfully connected LV clients to a server written in C# (ASP.NET Core) so this is likely a network/setup issue and not a general issue with grpc-labview. Error -1014 corresponds to the UNAVAILABLE gRPC status code. From my experience, that error code happens if the server isn't running on that port, there is a proxy/firewall preventing connection to that machine, you are using the wrong scheme in the URL (http vs https), or there is something else in the server configuration that is causing the connection to get rejected. Usually console logging on the server can help diagnose some of this.

suresh06-lv commented 1 month ago

Hi Jason, Thanks for the reply. We were able to connect the LV client to the C# GRPC server for a sample greeter service. It works fine and the message were passed as expected.
May I know whether you tried connecting to the GRPC server given at grpc-teststand-api. We also tried this case by providing the certificate files to the client and still got no luck. All these tests were done by disabling the firewalls.

jasonmreding commented 1 month ago

I don't have any experience with that gRPC API/server so it's difficult to say what might be going wrong. Are you able to connect to the server from the C# client provided in that repo? You might want to open an issue under that repo and seek help from others that are more familiar with the server. My best guess at this point is the server defaults to a secure connection by default, and you haven't configured the server for non-secure connections. Either that or the client connection requires other metadata to successfully connect. If you look at the way grpc channels are created in that repo, you'll see that all insecure communication appends a "connection-id" header to the request. Unfortunately, grpc-labview doesn't currently expose a way to attach http headers to RPC calls so you are kind of out of luck if that is a requirement. Either that, or you will have to try secure connections. Again, I would seek guidance from a maintainer of that repo.

suresh06-lv commented 1 month ago

I have a issue raised in the other repo as well(https://github.com/ni/grpc-teststand-api/issues/19) and already tried the cases of creating a non-secure connection, firewalls, different ports etc. But the http headers weren't working. Is it actually required to use the http/https for the address field in grpc-labview for this use case?

jasonmreding commented 1 month ago

I'm not certain what validation the underlying grpc libraries will perform if you supply http/https as part of the server address. However, it's not required. From the grpc-labview perspective, whether you get a secure or insecure connection is determined by the certificatePath string passed to Create Client.vi. You can see the code here.