WCF:传输文件时tcp服务超时
我有一个WCF服务,它使用tcp进行通信。当我尝试将文件从客户端传输到服务时,如果我在客户端和服务中的配置文件使用本地主机作为url的同一台计算机中进行传输,则没有任何问题 但是,如果当客户端位于lan中的其他计算机中时,我尝试执行相同操作,则会出现以下异常: System.TimeoutException:此请求操作已发送到网络。tcp://192.168.1.5:7997/CMMSHost 在配置的超时(00:01:00)内未收到答复。分配给此操作的时间可能是较长超时的一部分。这可能是因为该服务仍在处理该操作,或者因为该服务无法发送回复消息。请考虑增加操作超时(通过将通道/代理转换为ICONTROCTURE通道并设置操作超时属性),并确保服务能够连接到客户端。 但是,如果我尝试使用其他操作,例如搜索信息或添加寄存器以及任何其他类型的操作,则应用程序工作正常 因此,问题在于文件的传输 在服务中,我使用以下配置:WCF:传输文件时tcp服务超时,wcf,tcp,Wcf,Tcp,我有一个WCF服务,它使用tcp进行通信。当我尝试将文件从客户端传输到服务时,如果我在客户端和服务中的配置文件使用本地主机作为url的同一台计算机中进行传输,则没有任何问题 但是,如果当客户端位于lan中的其他计算机中时,我尝试执行相同操作,则会出现以下异常: System.TimeoutException:此请求操作已发送到网络。tcp://192.168.1.5:7997/CMMSHost 在配置的超时(00:01:00)内未收到答复。分配给此操作的时间可能是较长超时的一部分。这可能是因为该
<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>
在客户机中:
<configuration>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10: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" />
<messa
谢谢。您的应用程序是否适用于以kbs为单位的小文件?如果是,则对于较大的文件,请使用transferMode=“Streamed”而不是transferMode=“Buffered”。您必须相应地更改配置
如果应用程序无法处理更小的文件,则应用程序存在问题。
构建应用程序并重新生成代理,然后尝试调试应用程序
您也可以参考这些链接
http://www.codeproject.com/Articles/33825/WCF-TCP-based-File-Server我发现绑定的sentTimeout为“00:01:00”,请尝试将其更改为更大的值。此外,如果您正在传输大于4MB的文件,请考虑将读数配额增加到更大的值。