Wifi disconnects during sleep I noticed recently that, when I would use my phone after it had been sleeping, wifi wouldn't be connected and it would have to connect.  I went into advanced wifi settings and ensured that "Keep Wi-Fi on during sleep" was set to "Always", but the problem remains.  Any ideas?

I have an HTC One and AT&amp;T.

Update #1: Went through troubleshooting with three different HTC techs. The last effort was to clear the boot partition cache and factory reset the phone. After doing both, however, the issue remained.  I learned that the AT&amp;T software is out of date and actually has never been updated since I've had the phone for 16 months.  I'm waiting for a level 2 HTC tech to send me the latest version.
Just as an addition: I stumpled across the same (plus another problem) while upgrading my nexus 5 from Lollipop to Marshmallow. Every time when the phone was at sleep mode (for example: while driving my car and phone rested in the pocket) and I walked into a know wifi it did not auto connect. 

Usually when I arrived at work, as soon as I exited at the parking lot I got notified for incoming mails or messages, but not anymore on Android 6. As soon as I unlocked the phone wifi automatically connected and everything was fine. But I always forget to do this and It sometimes took hours before I realized I haven't done this step and messages won't get sent to me since I was not connected to the wifi until I picked up the phone from the pocket and unlocked it once.

I looked through all the settings and policy stuff, and finally I found something that worked:

Under Settings -> Power -> ... -> Power Optimimization you can switch the list from "unoptimized apps" to "all apps". Then search for "Google Connectivity Services" and disable the power optimisation for this system app.

After I've done it finally autoconnects to known wifis while my phone is in my pocket.

UPDATE
I just wanted to leave a note, that there was a small update a couple of days/weeks ago that brought back the not autoconnect issue to me, Power Optimization did not work for me anymore. Still have this issue, I will do a clean Android 6 install in the next weeks and look if the issue still exists. If yes I will stick with Android 5.x

UPDATE2
There was another update a while ago that almost "fixed" this problem.