Recently I found that my raspberry Pi WiFi adapter with Realtek 8192cu chip will be turned into a suspend or sleep mode after awhile with no connectivity. That is very inconvenience because I have to restart or wire it with ethernet cable if the connection is dropped. After doing some research, I found a solution on Stackoverflow.
It is because the adapter has power management features enabled by default. To disable it so that the Wifi connection can keep alive, just add a configuration file for the adapter.
sudo nano /etc/modprobe.d/8192cu.conf
Add this line in the file:
options 8192cu rtw_power_mgnt=0 rtw_enusbss=0
Reboot the Raspberry Pi, and the WiFI connection will be stay alive!