【问题标题】:WCF On Azure size issuesWCF 关于 Azure 大小问题
【发布时间】:2013-10-22 11:26:46
【问题描述】:

我找到了离我的问题不远的帖子,但仍然无法解决这个问题,所以请不要说它是重复的,并尝试提供帮助。

我在 Azure 上托管了一个 Web 服务。

当调用具有大量(不是那么大)数据的特定方法时,我收到一般错误:“底层连接已关闭:接收时发生意外错误。”

我知道这与大小有关,因为请求中有一个大字符串,当它大约 4.5 MB 时一切正常,当请求大约 5 MB 或以上时,请求失败并出现一般错误。

据我所知,web.config 处于最大大小:

<bindings>
  <webHttpBinding>
    <binding name="myWebHttpBinding" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" receiveTimeout="00:05:00" closeTimeout="00:05:00" openTimeout="00:05:00" sendTimeout="00:05:00"  >
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647"
                    maxNameTableCharCount="2147483647" />
      <security mode="Transport">
        <transport clientCredentialType="None"/>
      </security>
    </binding>
  </webHttpBinding>
</bindings>

这是方法的声明方式:

[WebInvoke(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, Method = "POST", UriTemplate = "/PublishDataItems")]
        ServerRespones PublishDataItems(DataItemRequest Request);

这就是我从客户端调用方法的方式:

WebClient proxy = new WebClient();
            proxy.Headers["Content-type"] = "application/json";
            MemoryStream ms = new MemoryStream();
            DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(DataItemRequest));
            ser.WriteObject(ms, myRequest);
            byte[] data = proxy.UploadData(URL + "PublishDataItems", "POST", ms.ToArray());
            MemoryStream stream = new MemoryStream(data);
            DataContractJsonSerializer obj = new DataContractJsonSerializer(typeof(ServerRespones));
            var result = obj.ReadObject(stream) as ServerRespones;

【问题讨论】:

    标签: c# wcf azure web-config webclient


    【解决方案1】:

    您可能会看到负载平衡器超时。关于断开连接之前的持续时间的详细信息并不多,但您的问题可能与请求持续时间而不是大小有关。更多详情请查看this MSDN blog entry

    【讨论】:

      【解决方案2】:
      猜你喜欢
      • 2010-11-25
      • 1970-01-01
      • 2023-04-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多