If you really have to keep the connection alive, run NOOP commands against the server, so that the control connection remains alive.
Either do it manually:
client.sendNoOp();
Or set the client to do it at fixed interval rates:
client.setControlKeepAliveTimeout(300); // set timeout to 5 minutes
But if you can avoid wasting resources, logout and disconect after the initial download phase, do your local processing and connect / login again for uploading afterwards.