WCF流式文件传输

发布于 2024-08-15 10:37:14 字数 480 浏览 6 评论 0原文

我正在尝试通过 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 连接上设置某个属性或其他内容以允许在客户端进行流传输?

I'm attempting to transfer some files through WCF, but as soon as the method is called from the client, I get the following message:

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'.

My method is wrapped in a try...catch, so if there's anything throwing an exception from within the method on the server, it should log it to a console window, but nothing is logged. I've also tried running the server locally and setting breakpoints on the method, and the method simply doesn't seem to be getting called.

Is there a property or something that needs set on the net.tcp connection to allow streaming on the client side?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

别忘他 2024-08-22 10:37:14

是否有财产或其他东西
需要在 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= 属性中指定该名称来在 中引用该配置。

有关更多详细信息,请参阅有关如何:启用流式传输的 MSDN 文档页面信息。

Is there a property or something that
needs set on the net.tcp connection to
allow streaming on the client side?

Yes - of course! You need to set up your client side config to use streaming - either in one direction (StreamedRequest if you want to upload stuff to the server, or StreamedResponse if you want to download from the server, or just plain Streamed if you stream both ways).

<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>

You need to define your binding configuration under a name (whatever you like), and then reference that configuration in the <endpoint> by specifying that name in the bindingConfiguration= attribute.

See the MSDN doc pages on How to: Enable Streaming for more detailed information.

我早已燃尽 2024-08-22 10:37:14

您应该在服务器上配置跟踪并打开日志以更好地解释正在发生的情况。
查看服务跟踪查看器工具

you should configure tracing on the server and open the log for a better explanation on what´s going on.
Take a look at the Service Trace Viewer Tool

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文