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?

