Modify retry middleware to retry on timeouts multiple times.