我遇到的罕见头痛问题真的需要一些好的解决方案。
背景是为了满足客户的要求,我开发了一个FileTransfer wcf服务,用于在互联网和企业内部网之间传输文件,因此我使用Windows服务通过提供两个协议来托管它,http和tcp,前者用于互联网内部网的数据传输和后者。但是,不幸的是,Windows服务主机处于恶劣的网络状态,更具体地说,它会随机丢失连接。
为了传输大文件的意图,我将sendtimout,receivetimeout,opentimeout和closetimeout设置为比较大的值,如“00:30:00”,但有时如果连接丢失或不稳定,则必须等待很长一段时间的发送 - 响应。
任何想法或棘手的解决方案?
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Folder" value="C:\Share\Test"/>
</appSettings>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="FileTransferHttpBinding" transferMode="Streamed" messageEncoding="Mtom" maxReceivedMessageSize="10067108864"
openTimeout="12:00:00" closeTimeout="12:00:00" receiveTimeout="12:00:00" sendTimeout="12:00:00">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
<netTcpBinding>
<binding name="FileTransferTcpBinding" transferMode="Streamed" maxReceivedMessageSize="10067108864">
<security mode="None">
</security>
</binding>
</netTcpBinding>
</bindings>
<services>
<service behaviorConfiguration="FileTransferServiceBehaviors" name="FileTransfer.FileTransferService">
<endpoint binding="basicHttpBinding" bindingConfiguration="FileTransferHttpBinding" contract="FileTransfer.IFileTransferService"/>
<endpoint binding="netTcpBinding" bindingConfiguration="FileTransferTcpBinding" contract="FileTransfer.IFileTransferService"/>
<endpoint address="mex" contract="IMetadataExchange" binding="mexTcpBinding" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8524/FileTransfer"/>
<add baseAddress="net.tcp://localhost:8525/FileTransfer"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="FileTransferServiceBehaviors">
<serviceMetadata httpGetEnabled="false"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>