0

真的需要一些好的解决方案来解决我遇到的罕见头痛问题。

背景是为了满足客户的需求,我开发了一个 FileTransfer wcf 服务,用于在 Internet 和企业的 Intranet 之间传输文件,所以我使用了一个 Windows Service 来托管它,它提供了两个协议,http 和 tcp,前者用于 Internet 数据传输,而后者用于后者用于 Intranet。但是,不幸的是,Windows 服务主机处于敌对网络状态,更具体地说,它随机失去连接。

为了传输大文件,我将 sendtimeout、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>
4

0 回答 0