OPC client trying to connect to OPC HDA server and end up in infinite waiting
0
votes
0
answers
45
views
I am quite new to OPC server/client. I have a service application serves as an OPC client, and trying to connect to OPC HDA server to data reading.
There is a list of tags which their value at a particular timestamp are to be read from OPC HDA server. My service will loop through the list of the tags. For each tag, it will do the following:
- connect to OPC HDA server based on the URL link given
- Read the tag attributes from HDA server
- disconnect from OPC HDA server
My code is as follows:
Public Shared Function GetOPCTagInfo(m_Tstamp As Object, m_tagname As Object, TagItemid As Object, serverurl As Object)
On Error Resume Next
Dim d(6) As String 'an array to store tag attributes read from OPC server
Dim KnownURL As URL = New URL
KnownURL = New URL(serverurl)
Dim server As Opc.Server = SampleClient.Factory.GetServerForURL(KnownURL)
myserver = server
myserver.Connect()
If myserver.IsConnected Then
d = newgetopcinfo(m_Tstamp, TagItemid, n) 'a function to read the item attributes from OPC server'
myserver.Disconnect()
Return d
Else
Return {"Fail to connect to server"}
End If
End Function
Currently I have encountered the issue that, when my service tries to connect to the HDA server in order to read the data for the tags, it got hang. I suspect that when it tries to connect to HDA server (myserver.Connect() ), it does not receive any response from HDA server and end up in infinite waiting.
Is there anyway to break this infinite waiting, so that at least it can go to next tag to repeat the process, or try to re-connect?
Asked by Zhang yy
(1 rep)
Mar 3, 2024, 06:11 AM
Last activity: Mar 3, 2024, 11:50 AM
Last activity: Mar 3, 2024, 11:50 AM