C# WCF流文件传输
我正试图通过WCF传输一些文件,但一旦从客户端调用该方法,我就会收到以下消息:C# WCF流文件传输,c#,wcf,file,streaming,net.tcp,C#,Wcf,File,Streaming,Net.tcp,我正试图通过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
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连接上设置的属性或内容,以允许在客户端进行流式传输
有没有什么财产或东西
需要在net.tcp连接上设置到
是否允许在客户端进行流式处理
是的,当然!您需要将客户端配置设置为使用流式传输-可以是单向的(StreamedRequest如果您想将内容上传到服务器,或者StreamedResponse如果您想从服务器下载,或者如果双向流式传输,只需简单地Streamed)
您需要在名称下定义绑定配置(无论您喜欢什么),然后通过在bindingConfiguration=
属性中指定该名称,在
中引用该配置
有关更多详细信息,请参阅上的MSDN文档页面。您应该在服务器上配置跟踪,并打开日志以更好地解释发生了什么。
看一看
<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>