03/15/2018
When I connect to the Opc server (opc-da), a new client is created. But when I close the connection, the client number does not change. When I connect again, a new client is created.
Each new connection creates a new client. The number of clients is increasing because I can not close the clients.
How can I reduce the client when I close the connection?
Used dll: OpcNetApi.dll, Version: 1.30.3.0
public void StopConnection()
{
GroupRead.DataChanged -= DataChanged;
GroupRead.Dispose();
Server.Disconnect();
Server.Dispose();
}
public Opc.Da.Server Server { get; set; } public Opc.Da.Subscription GroupRead { get; set; } public Result StartListening() { Result result = new Result(true); try { var surl = string.Format("opcda://{0}", MyOpcClientClass.ServerName); var url = new Opc.URL(surl); Server = new Opc.Da.Server(new OpcCom.Factory(), null); Server.Connect(url, new Opc.ConnectData(new System.Net.NetworkCredential())); Server.ServerShutdown += ServerShutdown; var group = new Opc.Da.SubscriptionState(); group.Name = MyOpcClientClass.GroupName; group.UpdateRate = MyOpcClientClass.Period; group.Active = true; GroupRead = (Opc.Da.Subscription)Server.CreateSubscription(group); GroupRead.DataChanged += new Opc.Da.DataChangedEventHandler(DataChanged); var items = this.MyOpcClientClassFieldMappingList.Select(i => new Opc.Da.Item { ItemName = i.OpcTagName }).ToList(); GroupRead.AddItems(items.ToArray()); } catch (Exception e) { // error log } return result; } private void DataChanged(object subscriptionHandle, object requestHandle, Opc.Da.ItemValueResult[] values) { try { // do smth... } catch (Exception e) { // error log } }
03/15/2018
The problem with version 2.01.105.1 is fixed. I tested it with a matrikon on my local computer. It works fine.
but There is a problem in live production. I connect to the opc server and I can select the data. It works fine but I get an error The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) when I terminate the connection.
firewall off
The rpc service is running
dcom settings ok
what is the problem?
03/29/2018
Hi !
I am experiencing same kind of problem using OPCAuto.dll (2.0.4.60) “Matrikon OPC Automation 2.0” where when I Disconnect() the OPC instance stays alive for ~45 seconds before it disappears from the Task manager’s processes’ list…
This creates a problem (COM Error) if I try to Connect() before the instance is flushed from memory…
The app is C# with .NET 4.5.6 and everything else (Validate, Add, Read) is working just fine.
Is there a way from .NET to force the OPC instance to close immediately upon Disconnect() ?
Thanks !!!
10/02/2014
First you should get a new SDK. The Automation Wrapper has been deprecated and not supported for a long time. With that said once you disconnect from a server it will go through a clean up process. It will need to complete and close process threads and disconnect from devices. Also it needs to verify that the disconnecting client is the last one so that it does not pull itself out from under another client.
You should talk to the server manufacturer and find out what timing and other requirements it has when a client disconnects from it.
One last thing and if I am wrong Randy will correct me. I am fairly certain that the server is only required to shutdown after a disconnect if it was started by a client connection.
1 Guest(s)