当我尝试上传附件时,我会随机收到此错误。
“无法从传输连接中读取数据:连接是 关闭。“
我有一个使用C#RallyRestAPI的导入功能,它从Test Track中提取数据并将其插入Rally并将附件中的副本复制到Rally。我的测试数据有3个附件,大小不一,分别为350k,63k和43k。当我运行我的导入器时,它会在不同的时间在不同的上传时出错。关于它没有一致性。有时三个都会失败,有时第二个会失败,第三个会失败。创建和更新故事看起来很好,所以看起来像是超时,但我不确定如何更改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);
}
}
答案 0 :(得分:0)
在我的测试中,我能够始终如一地上传大小达到5 MB的RAL限制的附件而不会出现错误。似乎与文件类型无关。
我建议提交支持拉力赛的案例(rallysupport@rallydev.com)。支持包含可用于识别瓶颈的工具 - 并尝试查看它们是否与服务器端/数据相关的问题或客户端连接问题。