This page explains how to disable the Wi-Fi optimization feature of your Android smartphone. Wi-Fi optimization will optimize the battery usage of your phone, by turning off Wi-Fi when your phone is idle. In some cases this may result in the disconnection from online services, so to disable this feature:
Go to Settings > Wi-Fi
Tap on the menu key (3 horizontal dots) > Advanced.