# WCF Problems



## Davidov541 (Apr 20, 2004)

Hey,

I am wanting to transfer a custom object across WCF to a simple client application. It has worked fine, except when one of the properties of the returned class is a Stream or a List<Stream>. It then returns the error below:

An error occurred while receiving the HTTP response to http://localhost:4567/WindowsDataProvider/PluginService. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.

Inner Exception Message:

The underlying connection was closed: An unexpected error occurred on a receive.

Inner Exception Message of that:

Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.

My current configuration has a basic HTTP Binding setup programmatically as follows:

int port = 4567;

ServiceHost sh = new ServiceHost(typeof(PluginService), new Uri(@"http://localhost:" + port.ToString() + @"/WindowsDataProvider/PluginService"));

BasicHttpBinding b = new BasicHttpBinding();

b.TransferMode = TransferMode.Streamed;

sh.AddServiceEndpoint(typeof(IPluginSvc), b, "");

ServiceMetadataBehavior behavior = new ServiceMetadataBehavior();

behavior.HttpGetEnabled = true;

sh.Description.Behaviors.Add(behavior);

WSHttpBinding binding = (WSHttpBinding) MetadataExchangeBindings.CreateMexHttpBinding();

binding.MaxReceivedMessageSize = 100000000;

sh.AddServiceEndpoint(typeof(IMetadataExchange), b, new Uri(@"http://localhost:" + port.ToString() + "/WindowsDataProvider/PluginService/mex"));

I need to keep setting up everything programmatically per my requirements. I think the problem has to do with the Stream not being allowed to be transfered over WCF. Is there anything I can do to let it come over? Thanks!


----------

