Add retry when server is lost

Add retry when server is lost
Some bugs corrections