在获取特定日期范围的录音时,我遇到了问题。我无法在本地重现该问题。但是我在生产中不断收到以下错误
“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);
}
}
}