Problem after wake from sleep (NoRouteToHostException)

For help and support with Universal Media Server
Forum rules
Please make sure you follow the Problem Reporting Guidelines before posting if you want a reply
Post Reply
rohmo
Posts: 3
Joined: Tue May 25, 2021 7:30 pm

Problem after wake from sleep (NoRouteToHostException)

Post by rohmo »

Hi,

First post here, although using UMS for years. It's never been any trouble until recently when I changed mobo/cpu.

First of all after this hardware change I had to choose the network adapter properly (mobo network card is now different). I think on some occasion I had to update Java and then I had to update UMS to newest version 10.x (so far I was using 6.8.0 if I remember correctly).

Not sure if all this is related, because recently I did not use UMS so frequently. However I noticed that now after waking my PC from sleep (usually I do it in the morning after putting the PC to sleep in the evening), the UMS was no longer visible on my TVs. At first I just hit restart server and it worked again just fine (although the need to go to my PC just to click that is a little annoying).

But it became obvious that whenever PC wakes, the UMS is gone. I checked the logs and now I think it is reproducible every time after sleep/wake that I can see this in the logs:
TRACE 2021-05-25 08:29:36.664 [UPNP-AliveMessageSender] Error when sending the ALIVE message: {}
java.net.NoRouteToHostException: No route to host: Datagram send failed
at java.net.TwoStacksPlainDatagramSocketImpl.send(Native Method)
at java.net.DatagramSocket.send(DatagramSocket.java:693)
at net.pms.network.UPNPHelper.sendMessage(UPNPHelper.java:379)
at net.pms.network.UPNPHelper.sendMessage(UPNPHelper.java:351)
at net.pms.network.UPNPHelper.sendAlive(UPNPHelper.java:227)
at net.pms.network.UPNPHelper.lambda$listen$0(UPNPHelper.java:400)
at java.lang.Thread.run(Thread.java:748)

This keeps repeating 6 times every 30 seconds or so. I can simply restart the server and everything is back to normal. Until next sleep/wake.

I upgraded to the most recent version now 10.5.0 but that didn't help. I started a new profile and added just two or three video folders, still not helped. It is the same error in the logs each time I wake my PC from sleep.

For years before I changed my mobo/cpu there was no issue like this and I can be sure because I automatically put my PC to sleep and then wake it next morning using system Task Scheduler. Evrything worked fine for years.

Not sure if there is a solution to this. What I am thinking is to add a script to somehow restart the UMS server from a command line - is this even possible? Any other suggestions please?

Edit: forgot to mention, my desktop has full network access after waking. I can check emails, browse web etc with no issue. Even the integrated Windows Media player DLNA shows up on my TVs. The only issue is only with UMS :-(
Nadahar
Posts: 1990
Joined: Tue Jun 09, 2015 5:57 pm

Re: Problem after wake from sleep (NoRouteToHostException)

Post by Nadahar »

My guess is that there's a change in the way the network card driver works, and that this one (as opposed to the last one) is slower to reinitialize during "wakeup" so that the UMS process is resumed before the network card driver is fully operational. Even though the network card driver later completes, it's "too late" for UMS which isn't made to reinitialize everything in the freak event that a network card "disappears" while it's running (which is what happens from UMS' POV). I've notices myself that some network cards are awfully slow to reinitialize after wakeup, which frequently causes all kind of issues (with other software, Outlook for example frequently gets "confused" by this and either reports strange errors or hang for a while).

While it would be possible to rewrite UMS to try to handle if the network card suddenly "disappears" (although it wouldn't be trivial, what does it do now - should it bind to another one - should it wait for the "missing one" - if so for how long...), I don't realistically see that happening. UMS has a somewhat complicated network arrangement, requiring network binding to take place a least 4 different places independently, so any such logic would have to be replicated to all those 4 "subsystems". In other words, I wouldn't wait for that..

I'm not sure what the solution is. It might work to change the "power state" of your network card to on when sleeping, it's usually possible to adjust this in the "power settings" somewhere. That might make the reinitialization quick enough that UMS will never notice.
rohmo
Posts: 3
Joined: Tue May 25, 2021 7:30 pm

Re: Problem after wake from sleep (NoRouteToHostException)

Post by rohmo »

Many thanks for comprehensive reply. I appreciate your input into insides of UMS, it helped me realize how this could be happening.
Additionally, you made me think that maybe by some settings in the BIOS, the network card operates somehow differently. The thing is that you triggered my memory that I disabled some wake events in the BIOS (not sure how it was called now), because I noticed my PC went awake during middle of the night some time ago. I will look into it, as well as the power settings to see if that helps.

Otherwise I will need to restart UMS by some script right after my PC wakes up. Either way, I will try to write back some feedback once I get on to it.
User avatar
mik_s
Moderator
Posts: 1114
Joined: Wed Aug 23, 2017 11:03 pm
Location: UK

Re: Problem after wake from sleep (NoRouteToHostException)

Post by mik_s »

This sounds very similar to my issue I had a few months ago and made an issue on GitHub about it. I managed to trace when it started to happen to version 9.8.1.

My network setup was a bit unusual then, using a wi-fi dongle for internet and my wired Lan connected to to a router for streaming. My computer would see a router on a wired connection so would prioritise that for internet so I had to alter some settings to make it use the dongle instead.

After a lot of messing around with settings I somehow fixed it, but was unable to recreate the problem so were not able to track down the root cause. And since I now have proper broadband I now have a more conventional network setup the issue was closed.

Is your network setup in a similar way?

You could reopen that Issue on GitHub and post your trace logs and maybe the devs can find the problem. I suspect it could be a change in one of the dependencies used by UMS but it is just a guess.
Logs are important for us to help, Please follow This Link before asking for support. Just a forum cleaner, Will help if I can but no expert.
rohmo
Posts: 3
Joined: Tue May 25, 2021 7:30 pm

Re: Problem after wake from sleep (NoRouteToHostException)

Post by rohmo »

Thanks for your follow up. However my network is plain simple - one ethernet wired connection from my PC straight to the home router. TVs connect to the same router by WIFI and one TV is near the router so I linked it by ethernet wire. After sleep/wake cycle everything else on my PC works without any issue - web/email but also for example I have logmein Hamachi - it can also reconnect correctly after waking.

Now I am thinking there could be some kind of a watchdog in UMS - if a problem shows up, it could restart UMS by itself. It could be the easiest solution, as Nadahar mentioned network binding takes place in at least 4 different places in UMS code independently.

I did not find any solution so far, I checked BIOS for wake-on-lan but that doesn't help here. I will try to install UMS as service and then restart the service using a script right after waking.
Nadahar
Posts: 1990
Joined: Tue Jun 09, 2015 5:57 pm

Re: Problem after wake from sleep (NoRouteToHostException)

Post by Nadahar »

You need to check the detailed "Power Management" in Windows, where you can make sure that the NIC has power. I don't remember where you find this on Windows 10, but for "proper" Windows versions it was Control Panel -> Power Management and then "Customize Profile" or something like that where you can adjust the details of what is actually shut down during sleep and not.

If that doesn't work, there might also be this option: https://techcommunity.microsoft.com/t5/ ... a-p/590996
User avatar
mik_s
Moderator
Posts: 1114
Joined: Wed Aug 23, 2017 11:03 pm
Location: UK

Re: Problem after wake from sleep (NoRouteToHostException)

Post by mik_s »

Could you help to track the cause of this down? You could try installing version 9.8.0 and see if it has the same behaviour, then try 9.8.1 (all versions available here)
If it is the same issue I had then then 9.8.0 should work normally but 9.8.1 will need a server restart to work properly after waking from sleep.

If that is the same for you could you reopen the issue on GitHub and see if the devs can walk you though some troubleshooting.
Resist temptation to try and fix it yourself though as it won't be any help to find the problem and you might not be able to recreate it if something you change does end up fixing it.
Logs are important for us to help, Please follow This Link before asking for support. Just a forum cleaner, Will help if I can but no expert.
paulvijayji
Posts: 1
Joined: Mon Jun 28, 2021 10:47 pm

Re: Problem after wake from sleep (NoRouteToHostException)

Post by paulvijayji »

I have the same issue. Any tips for solution?
Post Reply