Is your wifi dongle going into power saving mode no matter what you do.
You turn off wireless power management from /etc/network/interfaces by adding the following line of code and it does not work
Instead try this:
Create a new 8192cu.conf file (using the nano editor) in the following location
insert the following code
options 8192cu rtw_power_mgnt=0 rtw_enusbss=0
This will disable the power management and prevent the wifi (ew-7811un) from going to “sleep”.