-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connected pop up not appearing after reconnecting in some situations #182
Comments
If I stop nut-server on the rpi and start it a minute later I see this in the Win-NUT logs after the connection is reestablished. The last line saying "UPS statuses have not changed since last update, skipping" is suspicious.
I cannot see in UPS_Device.vb where variable oldStatusBitmask gets changed when Socket_Broken happens. Shouldn't some sort of flag be set so that the notification of the connection being reestablished is not skipped? |
Hi, Thanks for giving the latest build another try and providing feedback! And also, thanks for diving in to the code to see if you could find out what's wrong. With regards to the status updating, I don't think that's a big concern since this is the only method that acts on the status changing, which is only to handle a few cases of the UPS switching between line power and battery, as well as a full shutdown signal. I'm not sure I see any reason to clear out/reset the old status bitmask during a reconnection event, but please let me know if I'm missing something. I think the log data you provided may have cut out the new logging statements I had added to the ToastNotifyIcon method, which I think still should've run. Could you please upload more of the log in case those messages are still there? |
I'm running the latest pre-release v2.3.8988 not the debug build. Machines on a UPS are important so a pre-release is already pushing it and a debug build is not possible. Is the extra logging code merged? I don't know the Win-NUT code at all... If you stop the NUT server and start it again 1 min later do you get actually get a Windows notification from Win-NUT when the connection is lost? Do you get actually get a Windows notification from Win-NUT when the connection is restored? I don't think my setup is special. I only get a Reconnection In Progress notification when the connection is lost. |
It is odd, I've tried simulating the server going down by disabling the network adapter on my PC, but maybe there's some special nuance to actually shutting down the NUT server. I just can't seem to reproduce the issue you've been facing, so I was hoping the extra logging I'd added might help in getting there. I totally understand the desire for stable software and how it would be uncomfortable running anything else for an extended period of time. If you could consider running this debug build just for a few minutes to grab a log file though, I think that could potentially help here. And sorry, I completely forgot to link it! If this is something you.could do, here's the build in question: https://github.com/nutdotnet/WinNUT-Client/actions/runs/10531599982 |
I installed Visual Studio Community and hacked something that made the "Connected" notification appear when the reconnection occurs. I added a log message if we are logging in twice and it was showing up in the log file so I tried a hack to avoid logging in again while reconnecting and it works. I don't know the code so there must be a better solution to handle the thrown exception but this should provide useful information as to what is happening.
|
It's possible the socket isn't resetting its logged in state when disconnected. I'll take a closer look later today and hopefully have another debug build up for you soon. |
Does the login on reconnect strategy need to handle both scenarios differently or does the NUT server consider any brief lost connection to be logged out? BTW the "Connected" toast debug log messages didn't appear in the case where the exception was thrown on double login. With the hack to avoid double login, the toast debug log messages appear (as do the Windows notifications). Looking forward to your next build. Sorry for the noob questions, I like to learn stuff... |
No worries at all about the questions, I'm glad you're curious and I appreciate everything you've done so far. A little background about logging in to NUT servers - it's actually not necessary a vast majority of the time and should only be done under specific circumstances. I'm tracking this info in #106 if you want a closer look. I made some big changes with connection code recently in #163 so that the Login command started being correctly called, and made it so that it's only called in the main WinNUT connection routine as long as the provided username is not empty. This is why I'm confused that your fix worked; the Login attempt is only made at the very end of the connected event logic (so the notifications should have been triggered already), and it shouldn't have interrupted anything anyways. Looking back at your last full log, the point where the notificaiton toast was supposed to appear still shows even though it looks like the client didn't attempt to login when your RPi came back up (also a mystery...)
That's very odd to me. I want to try testing with my own VM instance of NUT running to fully emulate your situation, although I may not be able to get to that for a few days. You also mention this exception which isn't present in your last full log as well - if you could please upload a debug log of the build linked above for me like you were doing before, that should help me get closer to the root of the issue. Thanks again for everything, and please keep asking more questions! |
I've cleared the "Login" text field in the latest pre-release which I use in "production" and the "Connected" notification now appears when the NUT server is restarted. I'll leave it that way for now but I'm still very interested in testing your next build. The additional log message above (or similar) that I added to the Login subroutine may be a good idea as it would have made identifying that this was login related much easier. |
I'd really appreciate it if you could upload a recent complete log file with this exception you've been mentioning as that will help me a ton. |
Here's my only debug log from my build that includes one "UPS is in an invalid state to login." message that I added. I then immediatelty added the hack so this exception message never happened again. Although my git pull was from the main branch I had manually added your pending pull request so the toast debug stuff is in there in addition to my change. Hope this helps. |
That helped a lot, thank you! I was finally able to reproduce the issue you were experiencing. It's possible my client wasn't even logging in on my other NUT server which explains why I wasn't seeing the issue. Now that I've setup a test NUT server for logging in, I've been able to understand that process a little better. It was pretty much exactly as you thought. An exception was being thrown because WinNUT thought it was already logged in. When that happened, further event handlers in WinNUT (like the notification toast) were skipped. Your hack worked because it avoided the exception like you were thinking. I've approached the problem a little differently, in that I have WinNUT properly unset the logged in flag when disconnecting so it will always sync up now and allow WinNUT to log back in when reconnecting. And from what I can tell, the NUT server doesn't care how the client disconnects, so you can always log back in again. If you could please, I'd like for you to once again test the newest debug build just to confirm that it works as expected. No need to provide any log info if everything is good. Once you can confirm for me, I'll merge and close this issue, then hopefully have a new pre-release up soon. Thanks again for all of your assistance with this, I'm sorry it ended up being such a simple problem! |
Not easy to notice a failed login when things work anyways without logging in... It works beautifully! I get the "Connected" notification at the right time and I even checked in the logs that the authentication is successful just before the reconnected message.
It's cool when everything makes sense in the end. I'll use the pre-release build in production when available and reinsert the previously cleared login name. Maybe leave a comment here about the new build when available so I get an email. Very pleasant cooperating with you. |
As I merged these changes, I realized that I have the main development branch half-way through implementing a new deployment system for WinNUT. If you can hang on for a little bit longer, I'd like to get this out of the way so future updates are easier. |
No rush. The latest pre-release is doing the job in not logged in mode. When the next pre-release comes out I'll try the logged in mode to be consistent with my linux NUT clients and to test your fix more thoroughly. |
Originally posted by @yoyoma2 in #65 (comment)
Log excerpt:
Connection code seems to be running OK, with WinNUT processing events. Unclear since there's no logging code if the toast trigger is running.
The text was updated successfully, but these errors were encountered: