Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WCF nettcpbinding“;“发送”;超时——所有数据传输后_C#_Wcf_.net 3.5_Timeout_Nettcpbinding - Fatal编程技术网

C# WCF nettcpbinding“;“发送”;超时——所有数据传输后

C# WCF nettcpbinding“;“发送”;超时——所有数据传输后,c#,wcf,.net-3.5,timeout,nettcpbinding,C#,Wcf,.net 3.5,Timeout,Nettcpbinding,我正在编写一个本地计算机客户机/服务器应用程序,它使用一个应用程序托管的WCF服务,通过一个双工通道(即,对等通信)通过nettcpbinding进行连接。出于传统原因,这是.NET3.5 此代码设置服务器: var netTcpBinding = new NetTcpBinding(SecurityMode.Transport); netTcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Wi

我正在编写一个本地计算机客户机/服务器应用程序,它使用一个应用程序托管的WCF服务,通过一个双工通道(即,对等通信)通过nettcpbinding进行连接。出于传统原因,这是.NET3.5

此代码设置服务器:

var netTcpBinding = new NetTcpBinding(SecurityMode.Transport);
netTcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;
netTcpBinding.Security.Transport.ProtectionLevel = ProtectionLevel.EncryptAndSign;

netTcpBinding.ReceiveTimeout = new TimeSpan(0, 0, 14);
netTcpBinding.SendTimeout = new TimeSpan(0, 0, 30);
netTcpBinding.OpenTimeout = new TimeSpan(0, 0, 30);
netTcpBinding.CloseTimeout = new TimeSpan(0, 0, 30);

netTcpBinding.ListenBacklog = 2;
netTcpBinding.MaxConnections = 200;
netTcpBinding.MaxBufferPoolSize = 10 * 1000 * 1000;
netTcpBinding.MaxBufferSize = 10* 1000 * 1000;
netTcpBinding.MaxReceivedMessageSize = 10* 1000 * 1000;
netTcpBinding.PortSharingEnabled = true;

netTcpBinding.ReliableSession.Enabled = true;
netTcpBinding.ReliableSession.Ordered = true;
netTcpBinding.ReliableSession.InactivityTimeout = new TimeSpan(23, 59, 59);

ISmartBrowserClientServiceCallback callback = new SmartBrowserClientServiceCallback();
InstanceContext context = new InstanceContext(callback);

smartBrowserServiceFactory = new DuplexChannelFactory<ClientService.ISmartBrowserClientService>(
    context,
    netTcpBinding,
    new EndpointAddress(uri));

this.channel = this.smartBrowserServiceFactory.CreateChannel();
var netTcpBinding=新的netTcpBinding(SecurityMode.Transport);
netTcpBinding.Security.Transport.ClientCredentialType=TcpClientCredentialType.Windows;
netTcpBinding.Security.Transport.ProtectionLevel=ProtectionLevel.EncryptAndSign;
netTcpBinding.ReceiveTimeout=新的时间跨度(0,0,14);
netTcpBinding.SendTimeout=新的时间跨度(0,0,30);
netTcpBinding.OpenTimeout=新的时间跨度(0,0,30);
netTcpBinding.CloseTimeout=新的时间跨度(0,0,30);
netTcpBinding.ListenBacklog=2;
netTcpBinding.MaxConnections=200;
netTcpBinding.MaxBufferPoolSize=10*1000*1000;
netTcpBinding.MaxBufferSize=10*1000*1000;
netTcpBinding.MaxReceivedMessageSize=10*1000*1000;
netTcpBinding.PortSharingEnabled=true;
netTcpBinding.ReliableSession.Enabled=true;
netTcpBinding.ReliableSession.Ordered=true;
netTcpBinding.ReliableSession.InactivityTimeout=新的时间跨度(23,59,59);
ISmartBrowserClientServiceCallback=新的SmartBrowserClientServiceCallback();
InstanceContext上下文=新InstanceContext(回调);
smartBrowserServiceFactory=新的DuplexChannelFactory(
上下文
有约束力,
新端点地址(uri));
this.channel=this.smartBrowserServiceFactory.CreateChannel();
此代码设置客户端:

var netTcpBinding = new NetTcpBinding(SecurityMode.Transport);
netTcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;
netTcpBinding.Security.Transport.ProtectionLevel = ProtectionLevel.EncryptAndSign;

netTcpBinding.ReceiveTimeout = new TimeSpan(23, 59, 59);
netTcpBinding.OpenTimeout = new TimeSpan(0, 0, 15); // timeout seconds are different to help debugging
netTcpBinding.SendTimeout = new TimeSpan(0, 0, 17);
netTcpBinding.ReceiveTimeout = new TimeSpan(0, 0, 19);
netTcpBinding.CloseTimeout = new TimeSpan(0, 0, 21);

netTcpBinding.ListenBacklog = 2;
netTcpBinding.MaxConnections = 100;
netTcpBinding.MaxBufferPoolSize = 10 * 1000 * 1000;
netTcpBinding.MaxBufferSize = 10 * 1000 * 1000;
netTcpBinding.MaxReceivedMessageSize = 10 * 1000 * 1000;
netTcpBinding.PortSharingEnabled = true;

netTcpBinding.ReliableSession.Enabled = true;
netTcpBinding.ReliableSession.Ordered = true;
netTcpBinding.ReliableSession.InactivityTimeout = new TimeSpan(23, 59, 59);

ISmartBrowserClientServiceCallback callback = new SmartBrowserClientServiceCallback(this.smartBrowserClient);
InstanceContext context = new InstanceContext(callback);

this.smartBrowserServiceFactory = new DuplexChannelFactory<ISmartBrowserClientService>(
    context,
    netTcpBinding,
    new EndpointAddress(new Uri(string.Format(CultureInfo.InvariantCulture, "net.tcp://localhost:{0}/Cpy.SmartBrowser.SmartBrowserClientService/", defaultPort.ToString(CultureInfo.InvariantCulture)))));

this.smartBrowserServiceFactory.Faulted += (sender, e) =>
{
    this.smartBrowserServiceFactory = null;
};

this.channel = this.smartBrowserServiceFactory.CreateChannel();
var netTcpBinding=新的netTcpBinding(SecurityMode.Transport);
netTcpBinding.Security.Transport.ClientCredentialType=TcpClientCredentialType.Windows;
netTcpBinding.Security.Transport.ProtectionLevel=ProtectionLevel.EncryptAndSign;
netTcpBinding.ReceiveTimeout=新的时间跨度(23,59,59);
netTcpBinding.OpenTimeout=新的时间跨度(0,0,15);//超时秒不同,有助于调试
netTcpBinding.SendTimeout=新的时间跨度(0,0,17);
netTcpBinding.ReceiveTimeout=新的时间跨度(0,0,19);
netTcpBinding.CloseTimeout=新的时间跨度(0,0,21);
netTcpBinding.ListenBacklog=2;
netTcpBinding.MaxConnections=100;
netTcpBinding.MaxBufferPoolSize=10*1000*1000;
netTcpBinding.MaxBufferSize=10*1000*1000;
netTcpBinding.MaxReceivedMessageSize=10*1000*1000;
netTcpBinding.PortSharingEnabled=true;
netTcpBinding.ReliableSession.Enabled=true;
netTcpBinding.ReliableSession.Ordered=true;
netTcpBinding.ReliableSession.InactivityTimeout=新的时间跨度(23,59,59);
ISmartBrowserClientServiceCallback=新的SmartBrowserClientServiceCallback(this.smartBrowserClient);
InstanceContext上下文=新InstanceContext(回调);
this.smartbrowservicefactory=新的DuplexChannelFactory(
上下文
有约束力,
新的端点地址(新的Uri(string.Format(CultureInfo.InvariantCulture),“net。tcp://localhost:{0}/Cpy.SmartBrowser.SmartBrowserClientService/”,defaultPort.ToString(CultureInfo.InvariantCulture()()));
this.smartbrowservicefactory.Faulted+=(发送方,e)=>
{
this.smartbrowservicefactory=null;
};
this.channel=this.smartBrowserServiceFactory.CreateChannel();
现在,当客户机使用一些数据调用服务方法时,服务会很好地接收这些数据,并对其进行操作,但由于某种原因,17秒后发送方上出现了
TimeoutException
,这是我为
SendTimeout
选择的值。我觉得这很奇怪,因为所有要发送的数据都已经立即发送了,我认为系统没有理由等待任何东西

此客户端/服务器应用程序将在具有单个服务和单个客户端的本地计算机上使用,只是点对点通信。但是如果我不能摆脱这个超时,我将不得不以一种肮脏的方式来解决它,这是我想要避免的


我遗漏了什么明显的东西?

服务器代码在完成请求服务时做了什么?它回来了吗?服务器完成该操作需要多长时间?代码返回一个响应,这在一秒钟之内完成。