I have a Sprint S4 that only did this on certain routers. I found 2 solutions. 1st is turn Wifi off while sleeping, but that is not ideal. The second is, if you have a rooted phone, installing "[ROOT] Disable IPv6" from the app store. Now works perfectly.