2009-12-17 125 views
2

我試圖通過WCF傳輸一些文件,但只要從客戶端的方法被調用時,我得到以下信息:WCF流媒體文件傳輸

The socket connection was aborted. This could be caused by an error processing 
your message or a receive timeout being exceeded by the remote host, or an 
underlying network resource issue. Local socket timeout was '00:10:00'. 

我的方法是裹着try...catch ,所以如果在服務器上的方法中有任何引發異常的情況,它應該將其記錄到控制檯窗口,但是沒有記錄。我也曾嘗試在本地運行服務器並在該方法上設置斷點,並且該方法似乎並沒有被調用。

是否有一個屬性或需要在net.tcp連接上設置以允許在客戶端進行流式傳輸?

回答

4

是否有 需要 的連接的net.tcp上設置屬性或東西允許在客戶端流?

是的 - 當然!你需要設置你的客戶端配置使用流 - 無論是在一個方向(如果你想上傳東西到服務器StreamedRequest,或StreamedResponse,如果你想從服務器上下載,或只是簡單的串流播放如果你流兩種方式)。

<system.serviceModel> 
    <bindings> 
    <netTcpBinding> 
     <binding name="streaming" 
      transferMode="StreamedResponse"> 
     </binding> 
    </netTcpBinding> 
    </bindings> 
    <client> 
    <endpoint name="StreamEndpoint" 
       address="..." 
       binding="netTcpBinding" 
       bindingConfiguration="streaming" 
       contract="IYourService" /> 
    </client> 
</system.serviceModel> 

您需要定義你的綁定配置下一個名字(任何你喜歡的),然後在bindingConfiguration=屬性指定名稱引用在<endpoint>該配置。

有關更多詳細信息,請參閱How to: Enable Streaming上的MSDN文檔頁。