[RPi3] Kodi doesn't reconnect automatically to WiFi after a blackout

  • Had a look at the journal now. Nothing obvious. iwd just fails telling me the key was invalid (which of course it is not as it works after the next boot). Unfortunately, only connmand is verbose, iwd not so much:

    Edited once, last by treysis (August 11, 2025 at 10:51 AM).

  • The "invalid-key" error is something internal to the wireless stack and has nothing to do with "passphrase" for the network. It's root cause is still unknown but poor signal strength is a regular factor in it being seen.

    Post the entire log somewhere else there's no point asking upstream devs to comment; it's the first thing they'll ask for.

  • Thanks. I can rule out poor signal strength as router and RPi4 are in direct vicinity of each other and also because the error is 100% reproducible and the workaround also works 100% of the time. Also both 2.4 and 5 GHz networks are affected. Once connection is established, there is no issue with it and I never had any dropouts/disconnects.

    I'll post the full log but it'll take some time to redact as there's lots of sensitive information (neighboring WiFi stations in particular) contained within.

    Can I somehow get the wireless stack to be more verbose in its output?

  • I had some similar issues in the past, and just added a small script to crontab to force a connman restart when there's no connection.

    Something like this:

    in crontab (each 3 minute of the hour, test connection. The --reset-network parameters restarts connman if needed):

    Code
    03 * * * * /storage/bin/network-connection-test.sh --reset-network

    the script:


    I just wanted to say a huge THANK-YOU to you for creating this solution which I believe has solved my LibreELEC WiFi connection inconsistencies. :thumbup::thumbup::thumbup:

    I'm running it on x86-64 with a cheap realtek WiFi card that intermittently (3 times out of 4) will not associate to the WAP before the boot / wait time finishes, leaving me with an inaccessible Kodi.

    It's not the WiFi network (Ubiquiti prosumer grade, multiple WAPs, etc) and it's probably not LibreELEC either - just the cheap WiFi card needing some time to think about things on bootup!

    Once again, kudos! <3

  • Followup on the above, unfortunately the script in its current form does not achieve the desired effect. It detects the network is down but performing a restart of connman does not resolve.

    At the moment I am manually toggling the "Active" setting in LibreELEC settings, which appears to completely reset the network stack and re-initialise the WiFi.

    How can I perform this same action via a CLI command?

  • So, since the issue is not magically going to disappear, I eventually found the time to capture the logs of iwd.

    Here is the log where the autoconnect after a powerloss fails:

    External Content pastebin.com
    Content embedded from external sources will not be displayed without your consent.
    Through the activation of external content, you agree that personal data may be transferred to third party platforms. We have provided more information on this in our privacy policy.

    And here is the log where autoconnect works after reboot/graceful shutdown:

    External Content pastebin.com
    Content embedded from external sources will not be displayed without your consent.
    Through the activation of external content, you agree that personal data may be transferred to third party platforms. We have provided more information on this in our privacy policy.

    I don't think it's only affecting a few users as mentioned in this infamous thread: invalid wifi key

    I see a lot of posts about this error, also a very long github issue: https://github.com/LibreELEC/LibreELEC.tv/issues/7166

  • The user with the problem always believes it affects "lots of users" but the large number of reports (from a small number of vocal people who repeat post) vs number of active installs doesn't substantiate the claim, and over time with upstream changes to iwd, the number of new or continuing reports has declined. There are for sure some users still impacted, and we'd love that number to decline further, but that's in the hands of iwd developers not ours, and wpa_supplicant has other issues that were mitigated in the switch to iwd, so regardless of which one is used we have a "You can please some of the people some of the time, not all the people all of the time" situation, so we favour progress and moving forwards, and there is no interest to revert.

  • I counted at least 30 people, and those are just the ones that spoke up about it. I wonder if iwd devs are actually aware about the issue. Furthermore, I can only find bug reports regarding LinreELEC, but I guess that is due to the small number of distributions having made the switch to iwd. Actually, I couldn't find any other that uses iwd by default.

  • The iwd developers are aware of our reports, I have personally flagged it and provided information multiple times, and maintain a discussion about it with them. The root cause is not obvious to anyone, but this is not uncommon with wireless issues due to the sheer number of variables involved and difficulty in investigating the issue; it's one of the annoying ones where nobody has been able to isolate the factors required to replicate it.

    NB: 30 = ~0.0001% of the userbase. Sorry that you are 1/30, but you are wildly over-imagining the problem.

  • Well, I believe it just hasn't been viewed isolated and is instead mixed with other unrelated WiFi issues. What is clear: THIS problem only (but always!) occurs when there was no graceful shutdown (reboot or boot after shutdown), but never occurs when the system was shutdown properly, on at least the RPi4 platform.

    It most likely affects everyone. It's just that many people went for cable as a workaround (or in general) and never noticed that their WiFi isn't working.

    So yes, the overall user base that insists on using WiFi might be low, but it's most likely every WiFi user out there.

    I'll try a different platform than RPi4 when I find the time.

  • I counted at least 30 people, and those are just the ones that spoke up about it.

    I'm wondering, beside that number is really small comparing to all RPi LibreElec users, how many of them doesn't using their devices, waiting for a solution, and how many switched to alternative methods (LAN cable, USB-wifi dongle with better antenna) and using it without issues. :/

    BTW, did you tried with the same wifi source every times? Maybe it's some kind of settings or something at your router what with the iwd in the RPi lead to that "bug". :/