06/29/2023
Hello, it seems both opc.da.server.IsConnected and opc.ae.server.IsConnected methods do not accurately report the connection status. What would be recommended way to monitor the connection status between OPC DA client and server, as well as OPC AE client and server?
My initial thoughts were:
For DA server, polling some da item.
For AE server, KeepAlive from subscription.
But are there any recommended logics from OPC Foundation?
Test environment and result:
My project requires local connection (the client and the servers run on the same PC) to OPC DA and OPC AE servers. If the client were successfully connected to the servers (DA or AE), but later on the servers were not available anymore (server shutdown), server.IsConnected continued report true.
One seconds interval connect status check threads were running for both OPC DA and OPC AE connections. server.IsConnected, and server.GetStatus().StartTime, ServerState, CurrentTime were logged.
Log:
// Server was shutting down, server.GetStatus().ServerState was failed already, but server.IsConnected was true.
OPC DA Connected: True
OPC DA Status: 15/04/2024 13.45.50, failed, 15/04/2024 13.46.55
OPC AE Connected: True
OPC AE Status: 15/04/2024 13.45.50, Running, 15/04/2024 13.46.55
OPC DA Connected: True
OPC DA Status: 15/04/2024 13.45.50, failed, 15/04/2024 13.46.56
OPC AE Connected: True
OPC AE Status: 15/04/2024 13.45.50, Running, 15/04/2024 13.46.56
// Server was down already, server.GetStatus().ServerState Exception E_FAIL, but server.IsConnected was true.
OPC DA Connected: True
E_FAIL
IOPCServer.GetStatus
OPC AE Connected: True
E_FAIL
IOPCEventServer.GetStatus
06/29/2023
Thanks Randy. Another question about OPC AE subscription process flow, what should be the recommended subscription process? Assume all calls were success, should the state be active already, when create the subscription? Or should the subscription state be modified after Refresh()?
1. Connect() => Create SubscriptionState as state.Active(false) => Create SubscriptionFilters filters=> Create Subscription(state) subscription => SetFilters(filters) => attach EventChanged callback => Subscription.Refresh => Set SubscriptionState.Active = true and Subscription.ModifyState().
2. Connect() => Create SubscriptionState as Active(true) => Create SubscriptionFilters => Create Subscription() => SetFilters() => attach EventChanged callback => Subscription.Refresh()
PS. If it’s wrong place to ask, I could create a new question as well.
1 Guest(s)