powered by simpleCommunicator - 2.0.49     © 2025 Programmizd 02
Форумы / WCF, Web Services, Remoting [игнор отключен] [закрыт для гостей] / Как при закрытии клиента и заново откр подкл к объекту сервера?
3 сообщений из 3, страница 1 из 1
Как при закрытии клиента и заново откр подкл к объекту сервера?
    #37757540
stinggga
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
В двух словах. При первом вызове через прокси класс создаётся объект на сервер. Но при закрытии клиента и открытии заново ошибка следующего вида - 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();
...
Рейтинг: 0 / 0
Как при закрытии клиента и заново откр подкл к объекту сервера?
    #37757542
stinggga
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
[ServiceContract(CallbackContract = typeof(IStatCallback), SessionMode = SessionMode.Required)] //поддержка сессий
...
Рейтинг: 0 / 0
Как при закрытии клиента и заново откр подкл к объекту сервера?
    #37757547
stinggga
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Код клиента
_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;
...
Рейтинг: 0 / 0
3 сообщений из 3, страница 1 из 1
Форумы / WCF, Web Services, Remoting [игнор отключен] [закрыт для гостей] / Как при закрытии клиента и заново откр подкл к объекту сервера?
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]