eignert

Usage of OSIsoft.AF.PI.PIServer.FindPIServer() adds unwanted entry in KST

Discussion created by eignert on Sep 25, 2012
Latest reply on Sep 26, 2012 by eignert

Hi @all,

 

I'm currently testing the latest AF SDK Beta 3 (2.5.0.4851).
I retrieve a PIServer object using the OSIsoft.AF.PI.PIServer.FindPIServer() method. This works as expected as long as I have a server entry in my PI SDK Utility where the machine name of the PI-Server is the same as the DNS hostname.
Let's assume the windows computer name is in my case is srvpi01 (srv = standard prefix for servers we are using) and the DNS hostname is the same. We have a DNS alias pi01 for this server. This is because of historic reasons. Normally, all users only use the DNS alias pi01 in their known servers table because it stays the same when we migrate PI-Servers to other hosts and they don't have to change their processbooks etc.

 

Case 1:
Known servers table / PI SDK Utility has a connection to srvpi01. Using the FindPIServer() method works fine.

 

Case2:
Known servers table / PI SDK Utility has a connection to pi01. Connection from all client applications works fine. I now use the FindPIServer() method by calling a method that contains the following two lines of code:

 
PIServer piServer = PIServer.FindPIServer("pi01"); 
piServer.Connect(); 

The result is an InvalidOperationException ("Sequence contains more than one matching element") at the call of the Connect()-method. At this point the known servers table already contains a new element srvpi01. To it seems like the FindPIServer() method adds an entry for the actual machine name to the KST. Executing the code a second time now gives me an exception at the FindPIServer method (InvalidArgumentException: An item with the same key has already been added.) When I remove the entry srvpi01 from the KST and try to add it manually I get an error message "The server or one of its members already exists in the Known Servers Table."
So for me the FindPIServer method shows a very stange and unwanted behaviour. Can anyone reproduce this behaviour? Is there a way to get around this or am I using the wrong methods? Any kinds of hints are highly appreciated!

 

Best regards
Thomas

Outcomes