which Windows service ensures network connectivity?
Solution 1
We have been making our services, that depend on the network begin started, dependent on the "Server" service. Its actual name is "LanmanServer". This has been working ok for us. If you look at its description it states:
Supports file, print, and named-pipe sharing over the network for this computer. If this service is stopped, these functions will be unavailable. If this service is disabled, any services that explicitly depend on it will fail to start.
Our thinking is that if the computer is ready to do thoes functions, then the network has to be started.
Solution 2
I use "Tcpip", "Dhcp", "Dnscache". Works OK for me.
Related videos on Youtube
![Lluís](https://i.stack.imgur.com/5ubr5.jpg?s=256&g=1)
Lluís
Updated on November 03, 2022Comments
-
Lluís over 1 year
I am doing a windows service that must have network connectivity when it starts. Code is in c# and I set the service dependent from others with
serviceInstaller.ServicesDependedOn = new string[] { "Tcpip" };
I can see dependency correctly entered on windows service manager, but after reboot my service fails to start because it can't connect to network, after host gets an IP the service starts correctly.
I tried with "Tcpip" and "Dhcp" services. Which service should it depend on?
service needs network connectivity since its purpose is to mount a unit through ssh
thanks!
-
vcsjones about 12 yearsYour service should gracefully handle not being connected to the internet. You can't depend on a service to know when you have an actual, valid IP address.
-
Lluís about 12 yearsthen, I guess I should retry the connection until it's successful
-
-
usr about 12 yearsThis is a good heuristic. In any case, you need to do retry logic I guess?
-
user957902 about 12 yearsWe are using WCF services hosted in a windows servicse with protcol net.tcp. Not sure if WCF has any internal retry logic, but is sure throws an exception is you try to open the ServiceHost before the Network has started.
-
Lluís about 12 yearsthanks! now service starts correctly on boot, although I'll should add the retry logic too.
-
Darxis about 4 yearsUnfortunately this method does not work in Windows Server 2019 :/
-
Joseph Willcoxson over 2 years@Darxis So did you find a solution for Server 2019?
-
Darxis over 2 years@JosephWillcoxson I resolved my issue but not using service dependencies, see my answer stackoverflow.com/a/70632661/699850