This is to save battery on your iOS device. To avoid this, change your device settings to prevent it from entering sleep mode.