You can use GWT Timer to keep connection active between server and client by just calling a RPC after an interval. RPC will do nothing other than keeping connection active.
You can cancel the timer once the long running task is completed or you can start it again before starting any task that takes more time.
Sample:
// Create a new timer that calls RPC that does nothing.
Timer t = new Timer() {
@Override
public void run() {
//RPC Call
}
};
// Schedule the timer to run once in 5 seconds.
t.schedule(5000);