C
C#2y ago
Denis

❔ .NET Service discovery

I have a gRPC server installed on a workstation in an on-premise local network. And I have client applications that are installed on one or more machines in the same network. I wish the client applications could search the network and automatically find the gRPC server. Afaik, this was/is possible with WCF Discovery. How should this be done for gRPC? Is there a library I could use? Assume that the server and client apps are installed in a non-enterprise environment - customers have bare-bones IT infrastructures.
7 Replies
JakenVeina
JakenVeina2y ago
I dunno if there are any standard protocols for this, but it should be relatively simple A) you should probably not have this scanning happen automatically. Only have it happen when explicitly initiated by the user B) you could setup a lower-level socket listener on the server that listens on its own dedicated port, for data packets with a particular data value/pattern, and then responds with a different data value/pattern. The advantage of this (in theory) is that clients can simply send a single broadcast packet to the whole subnet, and all servers that hear it will respond. The disadvantage is that you'll need that additional open port on the server, and you'll probably want to coordinate with your IT department in general before you introduce traffic into the network that they won't recognize. C) You can just setup a simple gRPC endpoint that sends empty responses (or maybe some API version info?) to empty requests. Something like /acknowledge. To make this work, you'll have to manually list out all IP addresses possible in the subnet, and scan each one, as gRPC is a TCP-based protocol, and TCP requires that connections be pre-established (I.E. you can't send broadcast packets, I believe)
Denis
DenisOP2y ago
A) Why not? Application starts up for the first time, does a scan. If it finds the server, it shall save the address. Otherwise the user will be notified of the unestablished connection. If the next application startup discovers that the server is unavailable, it shall repeat the process as if it was the first ever startup. Is there something wrong with this approach? B) Do you know of a library I could you to reduce my development efforts? C) And if I skip gRPC and use something else entirely to establish the connection/find the server? What could I use? @ReactiveVeina ?
JakenVeina
JakenVeina2y ago
A) That's also fair I guess. Basically, just don't continuously scan and spam the network. And maybe only do that during startup if the last server you were using isn't responding. B) Not really, no. There might be a library out there for building custom low-level data protocols. C) See B)
Denis
DenisOP2y ago
Thank you!
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Sleepwalk
Sleepwalk17mo ago
Hey @Denis, I implemented something very similar to this a couple years ago. The service ran on a raspberry pi inside a piece of industrial equipment, a client running on a laptop would need to connect to it, they both needed to be on the same LAN, and that LAN might have multiple copies of that equipment that you could connect to. I didn't find anything lying around that really fit what I needed, so I implemented my own discovery service using UDP broadcast packets. The service ran a UDP client that listened on a particular port. Whenever it received any message on that port, it would send a UDP message back to the sender that just had the ASCII encoded name of the application. In the client, when the user wanted to connect to a device, it would UDP broadcast on all network interfaces to the target port, and also listen for any UDP messages sent to the IP address of the interface. Any messages it got that contained the application name would be verified (I had a GRPC function to return some basic information about the particular device), and added to a list that the user could choose from. That worked well enough for my needs.
Accord
Accord17mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server