Android 4.4.2 on nexus 4/7, wifi connection loss I have a Nexus 4 and a Nexus 7 (2013). 
Recently I've upgraded my wifi router as part of moving to VDSL.
The problem:
The android devices disconnect from the wifi after some time, I can not reproduce or find the exact time it takes for it to disconnect. After the connection loss the device still "think" it is connected to the wifi (and even shows signal strength), however there is not connection.

I've noticed that problem with the first router I brought (router+vdsl modem netgear vegn2610). At first I thought that the router is the problem since I didn't have that problem with my old router (tplink 841n). So I changed it to d-link 6850u (another router+vdsl modem combo from my ISP). The second router has the same problems.
Notice that other devices (PCs and laptops) do not suffer from this problem.

Both of the routers are 11agn routers and both are capable of 2.4GHz and 5GHz frequencies. The problems are present on both radios.

Is there anything in the wifi radio/protocol configuration that might be causing this problem?

Thanks a head!
this looks like the typical hassle with Qualcomm's WiFi chips and some routers. Both Nexus 4 and 7 use a WiFi chip manufactured by Qualcomm. Depending on your router's configuration those chips will stop responding after some time when the device is in standby.

A temporary quick fix for this problem is to assign a static IP to your devices instead of using DHCP. This can be done in most routers using a MAC->IP mapping.

If this doesn't help, you can stop reading now.

There are three other methods of fixing (of which one will require root):

Non-root:


Go to WiFi settings -> Advanced and set your frequency to 2,4 GHz only (this will work at a 50% chance)
Go to WiFi settings -> Advanced and disable "WiFi Optimisation" (WARNING: this can lead to a huge battery drain in busy networks)


Root:


Open a file explorer (e.g. ES Explorer) with root privilegs, move to /etc/wifi and open the file WCNSS_qcom_cfg.ini.
Edit these three parameters so that they will all be enabled (=1):


gEnableActiveModeOffload=1
hostArpOffload=1
hostNSOffload=1

Save the file and reboot your device.


A little bit of explanation: 

The feature that is messed up in Qualcomm's configuration file is ARP - Adress Resolution Protocol. ARP is meant to map a hardware's MAC adress to it's IP adress so the router can directly call the connected hardware via MAC adress. Usually the router periodically sends ARP requests to connected devices to ensure they're still in the network. When the device is awake and the CPU is active, it will deal with the ARP request and everything goes well. 

Once the CPU is asleep, it's the WiFi chip's job to deal with ARP requests so that the CPU needn't to be powered on every time an ARP request arrives. If ARP-Offloading is disabled though, the chip won't respond to the request and the router will kick the device out of its IP&lt;->MAC map, which eventually leads to a dead connection.

When you assign a static IP, the whole ARP stuff is not needed obviously.
Disabling WiFi Optimisation will make the CPU inspect every packet so it will deal with ARP instead of the WiFi chip. The problem here, that this will hinder the device from going into power save mode.

I personally had the same WiFi problems until I manually fixed my .ini the way I described above. It took me nearly half a year to figure the problem out. I hope that I can help you with that!

Best regards!

DISCLAIMER: I'm not responsible if you harm your phone or data.