【问题标题】:wcf exception: The server did not provide a meaningful replywcf 异常:服务器没有提供有意义的回复
【发布时间】:2012-06-26 14:46:57
【问题描述】:

我有一个使用 tcp 绑定的服务,该服务允许客户端与数据库交互。我使用 EF 和自我跟踪实体。

我想做的一件事是将文件存储在数据库中,为了不使线路过载,我有两个表及其对应的实体。一个表 Documents,包含文档的信息(类型、大小...等),另一个表 Files,存储二进制信息,即文件。

嗯,在本地,当我在同一台计算机上运行客户端和服务时,我可以存储我想要的文件。我尝试使用 6MB 的文件。但是如果我在同一局域网的其他计算机上运行客户端,那么我会遇到很多问题。

例如,如果我尝试存储一个 50kB 的小文件,我没有问题,但如果我尝试存储 6MB 的文件,则会出现不同的错误。

例如,如果我在客户端配置一个低超时时间,例如 1 分钟,我会收到错误:

System.TimeoutException:发送到 net.tcp://192.168.1.5:7997/CMMSHost 的请求操作未在配置的超时 (00:01:00) 内收到回复。

如果我将客户端配置为 10 分钟超时,则会收到以下错误:

服务器没有提供有意义的回复

该服务托管在 wpf 应用程序中,并且在将文档添加到数据库中的服务的 Begin 方法中,我发送带有日志的文本以了解是否接收到调用。当我收到一些错误时,没有收到调用,所以我认为问题可能是自我跟踪实体由于某种原因没有到达服务。

我的服务的 app.config 如下:

<endpoint address=""
                  binding="netTcpBinding"
                  bindingConfiguration="tcpBinding"
                  name="NetTcpBindingEndpoint"
                  contract="GTS.CMMS.Service.IService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>

        <endpoint contract="IMetadataExchange" binding="mexTcpBinding" address="net.tcp://localhost:5000/mex" />
      </service>
    </services>

    <behaviors>
      <serviceBehaviors>
        <behavior name="behaviorConfig">
          <!--
          <serviceMetadata httpGetEnabled="true" />-->
          <!--Necesario para poder enviar excepciones desde el servicio al cliente.-->
          <serviceDebug includeExceptionDetailInFaults="true"/>
          <serviceThrottling maxConcurrentCalls="100" maxConcurrentSessions="100" />
          <serviceMetadata/>
        </behavior>
      </serviceBehaviors>
    </behaviors>


    <bindings>
      <netTcpBinding>
        <binding name="tcpBinding" maxBufferSize="67108864"
                      maxReceivedMessageSize="67108864" maxBufferPoolSize="67108864"
                       transferMode="Buffered" closeTimeout="00:00:10"
                       openTimeout="00:00:10" receiveTimeout="00:20:00"
                       sendTimeout="00:01:00" maxConnections="100">
          <security mode="None"/>
          <readerQuotas maxArrayLength="67108864" maxBytesPerRead="67108864" maxStringContentLength="67108864"/>
          <reliableSession enabled="true" inactivityTimeout="00:20:00" />
        </binding>
      </netTcpBinding>
    </bindings>
  </system.serviceModel>

而客户端配置是:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="NetTcpBinding_IService" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:01:00" sendTimeout="00:01:00"
          transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
          hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288"
          maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:20:00"
            enabled="true" />
          <security mode="None">
            <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
            <message clientCredentialType="Windows" />
          </security>
        </binding>
      </netTcpBinding>
    </bindings>
    <client>
      <endpoint address="net.tcp://192.168.1.5:7997/CMMSHost" binding="netTcpBinding"
        bindingConfiguration="NetTcpBinding_IService" contract="IService"
        name="NetTcpBinding_IService" />
    </client>
  </system.serviceModel>
</configuration>

我使用大的读取引号,试图丢弃问题是文件大小的问题,但问题仍然存在。

谢谢。

【问题讨论】:

    标签: wcf exception tcp


    【解决方案1】:

    我不认为这是与 WCF 相关的问题。我认为它与您的 IIS 相当相关。 您可以在 web.config 中尝试以下代码 sn-p 吗?

    <system.webServer>
            <security>
                <requestFiltering>
                    <requestLimits maxAllowedContentLength="524288000"/>
                </requestFiltering>
            </security>
    </system.webServer>
    

    【讨论】:

    • 好吧,我已将安全性配置为无,并且是自托管服务。激活安全并设置requiestFiltering参数会更好吗?
    猜你喜欢
    • 2011-08-13
    • 2011-02-08
    • 1970-01-01
    • 2012-11-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-02
    相关资源
    最近更新 更多