Wrap connections with retry code