2 Replies Latest reply on Dec 21, 2016 1:25 PM by Anatoly

    How to connect to PI server using only host and port


      Hi everyone,


      I'm trying to connect to PI data server via AF SDK 2.8.6. I assume that PI Client requires default AF server to configure connections to PI servers. Is there a possibility to connect to data server via AF SDK without configuring connections in PI client and just using host and port?

        • Re: How to connect to PI server using only host and port

          Hello Anatoly,


          You don't need an AF Server connection defined to be able to connect to a PI Data Archive node via AF SDK. You however need to add / have the PI Data Archive host in the list of known servers. While OSIsoft.AF.PI.PIServers represents the Known Servers Table (KST), OSIsoft.AF.PI.PIServer is the representation of the connection object. If your PI Data Archive host is not in the KST while you are connecting, it will be added automatically when the connection can successfully be established. There's usually no need to specify a port as the default port 5450 is assumed. You can however access  the port property via the ConnectionInfo.Port.

          The following sample will raise an NullReferenceException, in case the referenced PI Data Archive cannot be connected.


                      string hostName = "PIServer";
                      OSIsoft.AF.PI.PIServers knownServers = new OSIsoft.AF.PI.PIServers();
                      OSIsoft.AF.PI.PIServer piDA = knownServers[hostName];
                      Console.WriteLine("PI Data Archive {0} is version {1}", piDA.Name, piDA.ServerVersion);


          Please note that you don't need to explicitly call Connect() or Disconnect() methods unless required e.g. if you like to use specific credentials. AF SDK will handle the connection automatically when you request for data.

          1 of 1 people found this helpful