If wlan connection hangs

Open Terminal and run
dmesg | tail -20

If you get lines like
wlan0: deauthenticating from 8c:…. by local choice (Reason: 3=DEAUTH_LEAVING)

wlan0: deauthenticated from ….(Reason: 15=4WAY_HANDSHAKE_TIMEOUT)

Add the time to /etc/wpa_supplicant/functions.sh file´s lines

local WPA_PIDFILE_WAIT
local MAX_WPA_PIDFILE_WAIT
WPA_PIDFILE_WAIT=”5″ ## original time was 0
MAX_WPA_PIDFILE_WAIT=”15″ ## original time was 5

Save and reboot

If that does not help, install the base kernel and drivers

sudo apt-get install linux-generic
sudo ubuntu-drivers autoinstall