添付ファイルをアップロードしようとすると、ランダムにこのエラーが発生します。
「トランスポート接続からデータを読み取れません: 接続が閉じられました。」
テスト トラックからデータを取得して Rally に挿入し、添付ファイルを Rally にコピーする C# RallyRestAPI を使用したインポート機能があります。テスト データには、サイズが異なる 350k、63k、および 43k の 3 つの添付ファイルがあります。インポーターを実行すると、異なる時間に異なるアップロードでエラーが発生します。それについて一貫性はありません。3 つすべてが失敗することもあれば、2 つ目が成功し、3 つ目が成功することもあります。ストーリーの作成と更新は問題ないようで、タイムアウトのように見えますが、RallyRestAPI でタイムアウトを変更する方法がわかりません。
C# と Rally RestAPI を使用してこの問題に遭遇した人はいますか?
これが私のアップロードコードです。Connect() を呼び出すと、RallyRestAPI オブジェクトが返され、そのオブジェクトにログインします。Rally への呼び出しごとに再ログインします (これを行う必要があるかどうかはわかりません)。
private string AddAttachment(string reference, string name, string content, long contentSize, string type) {
var restAPI = Connect();
try {
var attachmentContent = new DynamicJsonObject();
attachmentContent["Content"] = content;
attachmentContent["Workspace"] = _workspace["_ref"];
attachmentContent["Project"] = _target["_ref"];
var result = restAPI.Create("AttachmentContent", attachmentContent);
if (result.Success) {
_logger.Info("Attached the relevant AttachmentContent.");
}
else {
throw new LoggedException("Could not attach attachment to '" + reference + "' due to the following errors\n" + GetErrorList(result.Errors));
}
var attachmentContentRef = result.Reference;
// DynamicJSONObject for Attachment Container
var myAttachment = new DynamicJsonObject();
myAttachment["Workspace"] = _workspace["_ref"];
myAttachment["Project"] = _target["_ref"];
myAttachment["Artifact"] = reference;
myAttachment["Content"] = attachmentContentRef;
myAttachment["Name"] = Path.GetFileName(name);
var contentType = "image/jpg";
if (!string.IsNullOrEmpty(type)) {
switch (type.Trim().ToLower()) {
case "doc":
contentType = "document/text";
break;
default:
contentType = type;
break;
}
}
myAttachment["ContentType"] = contentType;
myAttachment["Size"] = contentSize;
result = restAPI.Create("Attachment", myAttachment);
if (result.Success) {
_logger.Info("Attached the relevant attachment.");
}
else {
throw new LoggedException("Could not attach attachment to '" + reference + "' due to the following errors\n" + GetErrorList(result.Errors));
}
return attachmentContentRef;
}
catch (Exception ex) {
throw new LoggedException("Unhandled exception occurred: ",ex);
}
}