在获取特定日期范围内的录音时,我遇到了一个问题。我无法在本地重现该问题。 但是我在生产中不断遇到以下错误
“ Twilio.Exceptions.ApiConnectionException:连接错误:GEThttps://api.twilio.com/2010-04-01/Accounts/AccountID/Recordings.json?DateCreated <= 2018-10-27T06:27:49Z- -> System.Threading.Tasks.TaskCanceledException:任务已取消。”
我们使用的代码在下面提到。该代码每2分钟运行一次
string accountSid = string.Empty;
string authToken = string.Empty;
if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["TwilioAccountSID"]) && !string.IsNullOrEmpty(ConfigurationManager.AppSettings["TwilioAuthToken"]))
{
accountSid = ConfigurationManager.AppSettings["TwilioAccountSID"];
authToken = ConfigurationManager.AppSettings["TwilioAuthToken"];
TwilioClient.Init(accountSid, authToken);
var deleteDateRange = DateTime.UtcNow.AddDays(-1);
var recordings = RecordingResource.Read(
dateCreatedBefore: deleteDateRange
);
if (recordings.Count() > 0)
{
foreach (var recording in recordings)
{
RecordingResource.Delete(recording.Sid);
}
}
}