Downloading streaming to WCF IIS 7 does not work

I have a wcf service that I configure to run under IIS 7. I have a set of streaming services for transmission. When I host the service in a console application myself, every thing works fine. But when the client connects to the iIS hosting, it seems to be buffered, and the client eventually disconnects. I used a violinist to determine that this client timeout occurs before the http request is executed.

Here are the server bindings.

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 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 } ); 

In contrast, the connection times out because the stream is infinite and the server must read the first few bytes and then close the stream.

+4
source share
2 answers

We recently had the same problem. When you host your service in IIS, whether you are streaming enabled or not, your service will buffer the entire message until it is sent. The reason for this is because it seems that WCF is not setting Response.BufferOutput to false (the default is true) when streaming is enabled on the service. The workaround can be found here:

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

+2
source

Do you close the stream in the client? If true, try closing only on the service side. Also, check if there is a OneWay operation. Can you place both snap nodes for endpoints?

0
source

Source: https://habr.com/ru/post/1306374/


All Articles