Моя проблема заключается в том, что соединение моего сеанса теряется, как только сеанс возвращается вызывающему методу.
Соединение установлено
Соединение потеряно
Код: Выделить всё
public OpcClient(string machineName, List opcTags, Opc.Ua.Client.Session opcSession)
{
//.......
OpcSession.KeepAlive += OpcSession_KeepAlive; //this never gets hit
//.....
}
public static async Task StartSession()
{
try
{
var config = new ApplicationConfiguration()
{
ApplicationName = "OPC UA Client",
ApplicationType = ApplicationType.Client,
SecurityConfiguration = null,
TransportConfigurations = new TransportConfigurationCollection(),
TransportQuotas = new TransportQuotas { OperationTimeout = 60000 },
ClientConfiguration = new ClientConfiguration { DefaultSessionTimeout = 60000 }
};
var endpoint = CoreClientUtils.SelectEndpoint("myServerDetails", false);
EndpointConfiguration endpointConfiguration = EndpointConfiguration.Create(config);
using (var session = Opc.Ua.Client.Session.Create(
config,
new ConfiguredEndpoint(null, endpoint, endpointConfiguration),
updateBeforeConnect: true,
sessionName: "My OPC UA Session",
sessionTimeout: 60000,
identity: new UserIdentity(new AnonymousIdentityToken()),
preferredLocales: null).Result)
{
Console.WriteLine("Session created successfully!");
// Interact with the session here
return session;
}
}
catch
(Exception ex)
{
return null;
}
}
Я вижу, что пакеты продолжают отправляться через Wireshark в течение примерно минуты после предположительного соединения. потерян.
Функция KeepAlive никогда не срабатывает, поэтому я подозревал, что там что-то не так, но это, видимо, автоматически обрабатывается в Opc.Ua.Client?
Любой очень благодарна за помощь!
Подробнее здесь: https://stackoverflow.com/questions/784 ... mmediately