TP Link TL-WPA4220 problem and fix

I purchased a TL-WPA4220 was unreliable. The connection did not stay up more than a day or so.

The device came with
Firmware version: 4.0.3 Build 20190326 Rel.43406
Hardware version: TL-WPA4220 v4.0

After a bit of browsing I found this https://community.tp-link.com/en/home/forum/topic/78910. Adding the following script on the Ubuntu Linux machine at the other end of the powerline adaptor solved the problem and it has been up for a week now.

while true
do
	ping -c 1 192.168.0.1
	sleep 60
done