C
C#13mo 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
JakenVeina13mo 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
Denis13mo 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
JakenVeina13mo 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
Denis13mo ago
Thank you!
Accord
Accord13mo 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
Sleepwalk12mo 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
Accord12mo 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
More Posts
How do you get the output type from a powershell script with System.Management.Automation?I am trying to figure out how to get the type specified in a powershell script `[OutputType([int])]`❔ Make interface deriving from another interface have a sealed implementation of a function...so that you dont have to write the same code for every child interface. details are in pastebin: ❔ Serialize objects from non-standard formatHello, I am trying to serialize objects from a non-standard format and dont know how to go about it ❔ Rider accepting completion deletes the next wordWhen I hit tab in Rider to accept a suggestion, it overwrites everything that comes after. Just likeHow is my code?https://github.com/Jamboi2007/The-vote-game/blob/ccaf87812c4509c17b88e97dd639251c96252bc4/Home❔ c# access variable from other threadI've been searching the web for a while and I cant seem to access a variable like this: `img.Source❔ MAUI Error when loading resources on loading pageI have a view that displays the `Cards` property as a `CollectionView`. The view model is populating✅ Writing a scuffed way to use an "assignment" (=) operatorObviously, there's no such thing as an assignment operator. I'd like to find some way around that. I❔ Timing issues whole end-to-end testing microservices.I'm using MassTransit to communicate between microservies. This creates a problem when I'm writing t✅ inputting list..```cs var size = int.Parse(Console.ReadLine()); List<int> arr = new List<int>(size);