【问题标题】:Rally API "Unable to read data from the transport connection: The connection was closed."Rally API“无法从传输连接读取数据:连接已关闭。”
【发布时间】:2013-02-20 03:21:48
【问题描述】:

我在尝试上传附件时随机收到此错误。

“无法从传输连接中读取数据:连接是 关闭。”

我有一个使用 C# RallyRestAPI 的导入函数,它从测试轨道中提取数据并将其插入 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);
            }
        }

【问题讨论】:

  • 感谢您提供详细信息。几个问题 - 你在使用代理吗?您的代码使用什么版本的 Rally Webservices?
  • 不,我没有使用代理,也没有在我的连接中指定特定的 API 版本,让它使用当前版本,我认为是 1.37。正在上传的数据的“内容”参数是使用“Convert.ToBase64String(fs)”的 Base64String。

标签: c# rally


【解决方案1】:

在我的测试中,我能够始终如一地上传大小不超过 5 MB 的 Rally 限制的附件而不会出错。似乎与文件类型无关。

我建议向 Rally 支持提交案例 (rallysupport@rallydev.com)。支持部门提供了可用于识别瓶颈的工具 - 并尝试查看它们是服务器端/数据相关问题还是客户端连接问题。

【讨论】:

    猜你喜欢
    • 2015-01-15
    • 1970-01-01
    • 2017-07-19
    • 1970-01-01
    • 2011-04-23
    • 2023-01-11
    • 1970-01-01
    • 2020-11-03
    • 1970-01-01
    相关资源
    最近更新 更多