I asked this question and found that normally setting the Wi-Fi sleep policy to Never would prevent my device from disconnecting from Wi-Fi when the screen is off, but it's not working. Even after setting this it still ends up disconnected. How can I get it to work properly?
I found this somewhere -- and it works for me.
Here is the solution that worked perfectly with me: the problem lies in the DHCP settings of the ADSL router.
FOLLOW THESE STEPS TO SOLVE THIS PROBLEM.......
Login to your router and go to DHCP settings (for belkin its 192.168.2.1) and find the item called leasing time. The default values of the leasing time is usually Forever -- and there is a bug with Android
All you have to do is to change the value of the Leasing time from forever to any other long value (depends on the routers options). Here I changed the value from forever to 2 weeks -- and since then I didn't have a single WIFI disconnect.
Checkout the Wi-Fi sleep policy under
Settings->wireless and network->wi-fi settings now press menu-> Advanced
As a workaround, try installing Wi-Fi Keep Alive. It can do things like keeping a Wi-Fi lock, pinging the router every ten seconds or just keeping the device awake.
Remember that some of the options of the app can be detrimental to battery life. (But if you want Wi-Fi to be always on, I doubt you care much about battery life.)
Go to the main screen-->Tap on applications symbol-->Go to Settings-->Then Wireless & Networks. Then now go to the WiFi and then move on advanced settings (shown as a symbol below the screen not on the screen but to will popup AFTER PRESSING THE LEFT Button)).you will find easily how to control it during sleep