server.IsConnected inaccurately reports status|Classic OPC: DA, A&E, HDA, XML-DA, etc.|Forum|OPC Foundation

Avatar
Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
Lost password?
sp_Feed sp_PrintTopic sp_TopicIcon
server.IsConnected inaccurately reports status
Avatar
Siyuan Xu
Member
Members
Forum Posts: 4
Member Since:
06/29/2023
sp_UserOfflineSmall Offline
1
04/15/2024 - 04:17
sp_Permalink sp_Print sp_EditHistory

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

Avatar
Randy Armstrong
Admin
Forum Posts: 1455
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
04/20/2024 - 05:39
sp_Permalink sp_Print

IsConnected indicates that the IConnectionPoint callback has been established. This is unrelated to the Server's actual status.

Avatar
Siyuan Xu
Member
Members
Forum Posts: 4
Member Since:
06/29/2023
sp_UserOfflineSmall Offline
3
04/22/2024 - 05:28
sp_Permalink sp_Print

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. 

Avatar
Randy Armstrong
Admin
Forum Posts: 1455
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
4
04/23/2024 - 07:05
sp_Permalink sp_Print

Calling Refresh before setting Active should cause nothing to happen.

Set Active after setting filters.

Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online:
Guest(s) 19
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1353
Posts: 4587