I just want to document this problem in case anyone else is having this same problem.
Problem description
Upon upgrading my WRT1900ACS router from OpenWRT 19 to 22, my phone's WIFI connection kept on getting "stuck" seemingly randomly. By "stuck" I mean that the phone would think it is connected, but the web browser would hang (waiting on the network) if I tried opening new pages. Every time this would happen I had to disable/re-enable the phone's WIFI and everything would be back to normal. A few minutes later, the same problem would occur.
Cause of Problem
After many tests, I realized that the connection was only hanging after 5 minutes being idle (e.g. because I was reading a long article). Upon scanning the WIFI settings I ran across a feature called Station inactivity limit which has a default value of 5 minutes.
Fix
Go into Network -> Wireless -> Edit -> Interface Configuration -> Advanced Settings -> increase "Station inactivity limit" to a large value.
Warning
Do not disable "Inactivity Polling". It does not do what you think it does.
"Station inactivity limit" drops idle connections after a certain timeout. "Inactivity polling" prevents idle connections from being dropped if they respond to the polling packet.
In my experience, "inactivity polling" is not good enough. If the router attempts to poll an idle mobile phone connection, and the phone is in power-saving mode, then it will not respond with an ACK packet. The router will drop the idle connection, but the phone won't know. The next time the phone tries using its connection, it just hangs. The response never comes back. Users are forced to manually reestablish a connection by disconnecting and reconnecting to the WIFI.
As far as I can tell, the only thing that works is increasing "Station inactivity limit" to a large value like a day. It is highly unlikely connections that are idle this long will ever come back. This avoids the hanging connection problem I discussed above.
I hope this saves others the hours I spent chasing this down
Proposal
I suggest shipping OpenWRT with a large "Station inactivity limit" value. Android phones don't handle silent disconnects gracefully and this problem is hard to diagnose. "Disassociate On Low Acknowledgement" (which is enabled by default) should be more than enough to kill dead connections.
Changelog
- 2024/06/28: Added a section explaining why it doesn't help to disable "Inactivity Polling".