最终,我在解决了这个问题之后,通过程序化配置的绑定进行了大量的试验和错误。
看起来,创建NetTcpBinding
时生成的绑定堆栈中的东西允许多个NetTcpBinding
共享一个端口。问题是我需要进行自定义绑定。
解决方案结束了创建自定义的基础上NetTcpBinding
结合。例如:
var lBinding = new NetTcpBinding()
{
SendTimeout = TimeSpan.FromMinutes(5),
ReceiveTimeout = TimeSpan.FromMinutes(5),
MaxConnections = 100,
ReliableSession = new OptionalReliableSession
{
Enabled = true,
Ordered = true,
InactivityTimeout = TimeSpan.FromMinutes(30)
},
Security = new NetTcpSecurity
{
Mode = SecurityMode.TransportWithMessageCredential,
Message = new MessageSecurityOverTcp { ClientCredentialType = MessageCredentialType.UserName }
},
MaxReceivedMessageSize = 524288
};
var lCustomBinding = new CustomBinding(lBinding);
// Edit the custom binding elements here
var lEndpoint = new ServiceEndpoint(lContract, lCustomBinding, new EndpointAddress(pServiceHost.BaseAddresses.First()));
André,这个自定义绑定是什么使得能够使用端口共享? – shambulator
嗨,抱歉,延迟响应。我已经改变了工作,并没有登录到SO。要点是:我不能在同一端口上运行多个CustomBinding端点,即使它们看起来包含相同的元素。我必须通过在构造函数中传递一个'NetTcpBinding'来构建'CustomBinding',然后对其进行修改。 –