Retry up to 5 times on IOError