Configure Streaming in Duplex Contract

Hi,

I want to transfer large files, I configure my service to allow streaming but when I send some files it gives me this error.

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 '23:59:59.9531250'.

This is my service config:

NetTcpBinding binding =newNetTcpBinding();

Uri baseaddress =newUri("net.tcp://" +Environment.MachineName +":8081/Service");

ServiceHost serviceHost =newServiceHost(typeof(Service), baseaddress);

TcpTransportBindingElement transport =newTcpTransportBindingElement();

transport.TransferMode =TransferMode.Streamed;

BinaryMessageEncodingBindingElement encoder =newBinaryMessageEncodingBindingElement();

CustomBinding cbinding =newCustomBinding(encoder, transport);

///binding confiiguration

binding.Security.Mode =SecurityMode.None;

binding.ReceiveTimeout =newTimeSpan(24,00,00);

binding.SendTimeout =newTimeSpan(24, 00, 00);

transport.MaxBufferSize =int.MaxValue;

transport.MaxBufferPoolSize =long.MaxValue;

transport.MaxReceivedMessageSize =long.MaxValue;

binding.ReaderQuotas.MaxBytesPerRead =int.MaxValue;

binding.ReaderQuotas.MaxArrayLength =int.MaxValue;

binding.ReaderQuotas.MaxStringContentLength =int.MaxValue;

binding.ReaderQuotas.MaxNameTableCharCount =int.MaxValue;

binding.ReaderQuotas.MaxDepth =int.MaxValue;

serviceHost.AddServiceEndpoint(typeof(ISafari), binding, baseaddress);

serviceHost.Open();

Console.WriteLine("Service is up! Press any key to stop");

Console.WriteLine("Service is listening on endpoint: " + baseaddress);

Console.Read();

serviceHost.Close();

and this is my client config:

string ip ="net.tcp://dm04:8081/Safari";

NetTcpBinding binding =newNetTcpBinding();

EndpointAddress address =newEndpointAddress(ip);

SafariCallback callback =newSafariCallback();

InstanceContext instantcontext =newInstanceContext(callback);

TcpTransportBindingElement transport =newTcpTransportBindingElement();

transport.TransferMode =TransferMode.Streamed;

BinaryMessageEncodingBindingElement encoder =newBinaryMessageEncodingBindingElement();

CustomBinding cbinding =newCustomBinding(encoder, transport);

binding.Security.Mode =SecurityMode.None;

binding.ReceiveTimeout =newTimeSpan(24, 00, 00);

binding.SendTimeout =newTimeSpan(24, 00, 00);

transport.MaxBufferSize =int.MaxValue;

transport.MaxReceivedMessageSize =int.MaxValue;

transport.MaxBufferPoolSize =long.MaxValue;

binding.ReaderQuotas.MaxBytesPerRead =int.MaxValue;

binding.ReaderQuotas.MaxArrayLength =int.MaxValue;

binding.ReaderQuotas.MaxStringContentLength =int.MaxValue;

binding.ReaderQuotas.MaxNameTableCharCount =int.MaxValue;

binding.ReaderQuotas.MaxDepth =int.MaxValue;

DuplexChannelFactory<ISafari> channelFactory =

newDuplexChannelFactory<ISafari>(instantcontext, binding, address);

Channel = channelFactory.CreateChannel();

when I try to send files it point me to this code:

Channel.GetStream(stream);

Why?

[8960 byte] By [Madz666] at [2008-1-8]
# 1
I don't know if this is the issue, but in that code your service has an address that ends with "Service" whereas the client address ends in "Safari"... the addresses shoudl match.
BrianMcNamara-MSFT at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 2
is streaming allowed in duplex? When I try to send large files my client stop responding?
Madz666 at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 3

Are you sending the file from your client or from your service. Also did you address the address mismatched mentioned above? Streaming is supported under Duplex.

DavidKreutz-MSFT at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...

Visual Studio Orcas

Site Classified