将流上传到 WCF IIS 7 托管服务无法正常工作

发布于 2024-08-27 19:10:23 字数 1572 浏览 4 评论 0原文

我有一个 wcf 服务,我正在将其设置为在 IIS 7 下运行。我已将该服务设置为传输模式的流式传输。 当我在控制台应用程序中自行托管服务时,一切似乎都工作正常。但是,当客户端连接到 iis 托管服务时,它似乎正在缓冲,并且客户端最终会超时。我已经使用 fiddler 来确定客户端超时发生在 http 请求发出之前。

这是服务器绑定。

var binding = new CustomBinding();
            binding.Elements.Add( new TextMessageEncodingBindingElement()
            {
                MessageVersion = MessageVersion.Soap12WSAddressing10
            } );

            var secBinding = SecurityBindingElement.CreateUserNameOverTransportBindingElement();
            secBinding.AllowInsecureTransport = true;
            binding.Elements.Add( secBinding );
            binding.Elements.Add( new HttpTransportBindingElement()
            {
                TransferMode = TransferMode.Streamed,
                MaxReceivedMessageSize = Int32.MaxValue,

            } );

客户端绑定:

var binding = new CustomBinding();
            binding.Elements.Add( new TextMessageEncodingBindingElement()
            {
                MessageVersion = MessageVersion.Soap12WSAddressing10
            } );

            var secBinding = SecurityBindingElement.CreateUserNameOverTransportBindingElement();
            secBinding.AllowInsecureTransport = true;
            binding.Elements.Add( secBinding );
            binding.Elements.Add( new HttpTransportBindingElement()
            {
                TransferMode = TransferMode.Streamed,
                MaxReceivedMessageSize = Int32.MaxValue,
                MaxBufferSize = 400
            } );

顺便说一句,连接超时,因为流是无限的,服务器应该读取前几个字节,然后关闭流。

I have a wcf service I am setting up to run under IIS 7. I have the service set to streaming for the transfermode.
When I self host the service in a console application every thing seems to work ok. But when the client connects to an iis hosted service it seems to be buffering, and the client eventual times out. I have used fiddler to determine that this client time out happens before the http request is even made.

Here is the servers binding.

var binding = new CustomBinding();
            binding.Elements.Add( new TextMessageEncodingBindingElement()
            {
                MessageVersion = MessageVersion.Soap12WSAddressing10
            } );

            var secBinding = SecurityBindingElement.CreateUserNameOverTransportBindingElement();
            secBinding.AllowInsecureTransport = true;
            binding.Elements.Add( secBinding );
            binding.Elements.Add( new HttpTransportBindingElement()
            {
                TransferMode = TransferMode.Streamed,
                MaxReceivedMessageSize = Int32.MaxValue,

            } );

And the client binding:

var binding = new CustomBinding();
            binding.Elements.Add( new TextMessageEncodingBindingElement()
            {
                MessageVersion = MessageVersion.Soap12WSAddressing10
            } );

            var secBinding = SecurityBindingElement.CreateUserNameOverTransportBindingElement();
            secBinding.AllowInsecureTransport = true;
            binding.Elements.Add( secBinding );
            binding.Elements.Add( new HttpTransportBindingElement()
            {
                TransferMode = TransferMode.Streamed,
                MaxReceivedMessageSize = Int32.MaxValue,
                MaxBufferSize = 400
            } );

As an aside the connection is timing out because the stream is infinite and the server should read the first few bytes and then close the stream.

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

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

发布评论

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

评论(2

心凉 2024-09-03 19:10:23

最近,我们遇到了同样的问题。当您在 IIS 下托管服务时,无论是否启用流式传输,您的服务都会在发送之前缓冲整个消息。其原因是,当在服务上启用流式传输时,WCF 似乎未将 Response.BufferOutput 设置为“false”(默认为 true)。可以在此处找到解决方法:

http://weblogs.asp.net/jclarknet/archive/2008/02/14/wcf-streaming-issue-under-iis.aspx

Recently, we had the same issue. When you host your service under IIS, no matter if you enable streaming or not, your service will buffer the entire message prior to sending it. The reason for this, is that it appears as though WCF does not set the Response.BufferOutput to "false" (default is true), when streaming is enabled on a service. A workaround can be found here:

http://weblogs.asp.net/jclarknet/archive/2008/02/14/wcf-streaming-issue-under-iis.aspx

伤痕我心 2024-09-03 19:10:23

您是否关闭客户端中的流?如果属实,请尝试仅在服务端关闭。
另外,验证其是否为单向操作。
您可以发布端点的两个绑定节点吗?

Are you closing the Stream in the client? If true, try closing just in the service side.
Also, verify if its a OneWay operation.
Can you post the both binding nodes, for the endpoints?

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