Add reconnect code with exponential retry