2013-08-06 5 views
-1

웹 서버에서 zip 파일을 다운로드하는 WCF에 웹 서비스가 있습니다. 나는 FtpWebRequest을 사용하여 해당 파일을 다운로드하고 있습니다. 내 네트워크가 다운되면 여기 내 코드파일 다운로드 시간이 오래 걸린다

public byte[] DownloadFile(string fileName) 
    { 
     int bytesRead = 0; 


     String downloadUrl = String.Format("{0}{1}/{2}", "ftp://xx.xx.xxx.xxx/datatransfer/", "folder", fileName); 
     FtpWebRequest req = (FtpWebRequest)FtpWebRequest.Create(downloadUrl); 
     req.Method = WebRequestMethods.Ftp.DownloadFile; 
     req.Credentials = new NetworkCredential("uname", "pass"); 
     Stream reader = req.GetResponse().GetResponseStream(); 
     //FileStream fileStream = new FileStream(localDestinationFilePath, FileMode.Create); 
     byte[] buffer = new byte[2048]; 
     while (true) 
     { 
      bytesRead = reader.Read(buffer, 0, buffer.Length); 

      if (bytesRead == 0) 
       break; 

      //fileStream.Write(buffer, 0, bytesRead); 
     } 
     return buffer; 
    } 

다운로드 너무 시간이 오래 걸립니다, 그리고 그것은 내 의 Web.config를 다음 오류

The remote server returned an error: NotFound. An exception of type 'System.ServiceModel.CommunicationException' occurred in System.ServiceModel.ni.dll but was not handled in user code

을 제공입니다

<?xml version="1.0"?> 
<configuration> 

<appSettings> 
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> 
</appSettings> 
<system.web> 
    <compilation debug="true" targetFramework="4.5" /> 
    <httpRuntime targetFramework="4.5" maxRequestLength="409600"/> 
</system.web> 
<system.serviceModel> 
    <bindings> 
    <basicHttpBinding> 
     <!--<binding maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" receiveTimeout="00:10:00" closeTimeout="00:10:00"> 
     <security mode="None" /> 
    </binding>--> 
    <binding closeTimeout="01:10:00" 
     openTimeout="01:10:00" receiveTimeout="01:10:00" sendTimeout="01:10:00" 
     maxBufferSize="2147483646" maxBufferPoolSize="2147483646" maxReceivedMessageSize="2147483646" 
     transferMode="StreamedRequest"> 
     <readerQuotas maxDepth="2147483646" maxStringContentLength="2147483646" maxArrayLength="2147483646" 
     maxBytesPerRead="2147483646" maxNameTableCharCount="2147483646" /> 
     <security mode="None">    
     </security> 
    </binding>  
    </basicHttpBinding>  
</bindings> 

<behaviors> 
    <serviceBehaviors> 
    <behavior> 
     <!-- To avoid disclosing metadata information, set the values below to false before deployment --> 
     <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/> 
     <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
     <serviceDebug includeExceptionDetailInFaults="true"/> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 
    <protocolMapping> 
    <add binding="basicHttpsBinding" scheme="https"/> 
    </protocolMapping>  
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 
</system.serviceModel> 
<system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    <!-- 
    To browse web app root directory during debugging, set the value below to true. 
    Set to false before deployment to avoid disclosing web app folder information. 
    --> 
    <directoryBrowse enabled="true"/> 
</system.webServer> 

</configuration> 

여기 내 결과는 입니다. ServiceReferences.C

<configuration> 
<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
      <binding name="BasicHttpBinding_IService1" maxBufferSize="2147483647" closeTimeout="01:10:00" 
         openTimeout="01:10:00" receiveTimeout="01:10:00" sendTimeout="01:10:00" maxReceivedMessageSize="2147483647"> 
       <security mode="None" /> 
      </binding> 
     </basicHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://localIP/WebService/Service1.svc" 
      binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1" 
      contract="MyService.IService1" name="BasicHttpBinding_IService1" /> 
    </client> 
</system.serviceModel> 

네트워크가 다운 때 큰 파일 을 다운로드 할 수있는 방법이 있나요 lientConfig. web.config에 변경 사항이 있습니까?

답변

1

아니요, 네트워크가 다운되었을 때 다운됩니다. 전선에 전기가 공급되지 않아 데이터가 없습니다. 하드웨어 장애에 대한 소프트웨어 솔루션은 없습니다.

네트워크가 다시 시작될 때까지 기다리거나 다른 네트워크 공급자 또는 두 번째 네트워크 또는 기타 하드웨어 구성을 통해이 작업을 수행 할 수 있지만 문제를 해결하려면 네트워크가 다운되지 않도록하는 것이 좋습니다. 첫 번째 장소.

+0

네트워크 중단 인터넷 속도 (다운로드 속도)가 느립니다. –

+0

그런 다음 오류 메시지에 설명 된대로 예외를 처리해야합니다. 네트워크 속도가 느린 경우 제한 시간이 초과되었을 수 있습니다. 네트워크가 비정상적으로 느린 경우에는 서비스 및 FTP가 기반으로하는 서비스 중단 및 TCP가 끊임없이 필요합니다. – nvoigt

관련 문제