|
Как при закрытии клиента и заново откр подкл к объекту сервера?
|
|||
---|---|---|---|
#18+
В двух словах. При первом вызове через прокси класс создаётся объект на сервер. Но при закрытии клиента и открытии заново ошибка следующего вида - The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it has been Aborted. Код сервера : IPHostEntry ips = Dns.GetHostEntry(Dns.GetHostName()); IPAddress _ipAddress = ips.AddressList[0]; urlService = "net.tcp://" + _ipAddress.ToString() + ":" + Config.Primaryrouter.ToString() + "/AutoFillingPayServer"; host = new ServiceHost(typeof(TransportFilling)); Console.WriteLine("ServiceHost ok"); NetTcpBinding tcpBinding = new NetTcpBinding(System.ServiceModel.SecurityMode.None); tcpBinding.TransactionFlow = false; tcpBinding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign; tcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows; tcpBinding.Security.Mode = SecurityMode.None; host.AddServiceEndpoint(typeof(IStatTransportFilling), tcpBinding, urlService); Console.WriteLine("NetTcp ok"); ServiceMetadataBehavior metadataBehavior; metadataBehavior = host.Description.Behaviors.Find<ServiceMetadataBehavior>(); ServiceDebugBehavior debug = host.Description.Behaviors.Find<ServiceDebugBehavior>(); if (debug == null) { host.Description.Behaviors.Add( new ServiceDebugBehavior() { IncludeExceptionDetailInFaults = true }); } else { if (!debug.IncludeExceptionDetailInFaults) { debug.IncludeExceptionDetailInFaults = true; } } Console.WriteLine("ServiceDebugBehavior ok"); if (metadataBehavior == null) { System.ServiceModel.Configuration.HostElement hostElement = new System.ServiceModel.Configuration.HostElement(); metadataBehavior = new ServiceMetadataBehavior(); metadataBehavior.HttpGetUrl = new Uri(" http://" + _ipAddress.ToString() + ":" + Config.Secondaryrouter.ToString() + "/AutoFillingPayServer"); metadataBehavior.HttpGetEnabled = true; metadataBehavior.ToString(); host.Description.Behaviors.Add(metadataBehavior); urlMeta = metadataBehavior.HttpGetUrl.ToString(); } host.Open(); ... |
|||
:
Нравится:
Не нравится:
|
|||
17.04.2012, 16:50 |
|
Как при закрытии клиента и заново откр подкл к объекту сервера?
|
|||
---|---|---|---|
#18+
[ServiceContract(CallbackContract = typeof(IStatCallback), SessionMode = SessionMode.Required)] //поддержка сессий ... |
|||
:
Нравится:
Не нравится:
|
|||
17.04.2012, 16:51 |
|
Как при закрытии клиента и заново откр подкл к объекту сервера?
|
|||
---|---|---|---|
#18+
Код клиента _AdressRouter = AdressRouter; _portnum = portnum; _ErrorMessage = ""; bool flag = true; if (_AdressRouter == "") _AdressRouter = "RAD"; if (_portnum == 0) _portnum = 5071; ePAddr = prc_lpr + _AdressRouter + ":" + _portnum.ToString() + "/AutoFillingPayServer"; NetTcpBinding tcpBinding = new NetTcpBinding(); tcpBinding.TransactionFlow = false; tcpBinding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign; tcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows; tcpBinding.Security.Mode = SecurityMode.None; EndpointAddress endpointAddress = new EndpointAddress(ePAddr); if (instanceContext == null) instanceContext = new InstanceContext(new TransportEvent()); proxy = DuplexChannelFactory<IStatTransportFilling>.CreateChannel(instanceContext, tcpBinding, endpointAddress); flag = checkRouter(proxy); if (!flag) return false; //proxy. IsOpenListener = flag; ... |
|||
:
Нравится:
Не нравится:
|
|||
17.04.2012, 16:52 |
|
|
start [/forum/topic.php?fid=19&msg=37757542&tid=1397253]: |
0ms |
get settings: |
8ms |
get forum list: |
12ms |
check forum access: |
4ms |
check topic access: |
4ms |
track hit: |
167ms |
get topic data: |
14ms |
get forum data: |
3ms |
get page messages: |
51ms |
get tp. blocked users: |
2ms |
others: | 14ms |
total: | 279ms |
0 / 0 |