13 Replies Latest reply on May 17, 2018 12:31 PM by gregor

    PI AF SDK application connection fail to PI DATA Archive

    Noga

      I am running an application on my local machine, that uses AF-SDK, and tries to connect to a PI-Server Data Archive that is located on a remote machine.

      I created a mapping authentication Identity on the remote machine in order for the application to connect using a Windows Authentication (username+password). Unfortunately when running the application I get the error: "Cannot connect to the PI Data Archive".

      I wonder what am I doing wrong? How can I connect to a remote PI-Server without using Trust authentication, but a mapping authentication?

        • Re: PI AF SDK application connection fail to PI DATA Archive
          LalBabuShaik

          Hi Noga Avr

           

          Could you please let us know how your application is running?

           

          On the machine you are running the application, Request you to check below steps,

           

          a) Open AboutPI SDK and check connections (try connect to PI Data Archive)

          b) Try using same user and password to authenticate with PI Data archive server and mapping should reflect same as defined earlier.

          c) If it is scheduled or running as a service, request you to configure logon.

          d) If you are running through IDE then request you to run the application using Run-As.

            • Re: PI AF SDK application connection fail to PI DATA Archive
              Noga

              Hi Lal,

              Thank you for your help.

               

              My application is running through IDE ( from within Visual Studio .NET).

              I've opened About SDK and connected to PI DATA Archive.

              I've used same user and password to authenticate with PI Data archive server and mapping.

              I'm running my application as Administrator.

              Unfortunately I'm still getting the same error: "Cannot connect to the PI Data Archive"

              When I'm running the application localy on the computer where my PI server is located, connection succeeds.

              remotely it fails.

               

              Noga

                • Re: PI AF SDK application connection fail to PI DATA Archive
                  John Messinger

                  Which overload of the PIServer.Connect() method are you using to make your connection? If you are relying on a PI Mapping for authentication to the PI Data Archive then you would either use the default parameter-less overload (which will pass the credentials under which you are running the Visual Studio IDE), or alternatively you might use the PIServer.Connect(NetworkCredential) overload to pass a specific Windows credential for authentication. Unless you have a very specific need for this, I would generally opt for the first overload.

                   

                  I would also examine the PI Server message log to see what credentials are actually being received and evaluated by the PI Data Archive for authentication when your application attempts to connect. If you are running the application remotely as Administrator, it may be that the credentials being passed aren't what you are expecting and therefore not matching your PI Mapping.

                   

                  John

                    • Re: PI AF SDK application connection fail to PI DATA Archive
                      Noga

                      When examining the Log messages on "About PISDK" section in the "PI SDK Utility", I see error:

                      PINS service may have stopped (error code=-2147220368).

                      Is that relevant to my problem?

                        • Re: PI AF SDK application connection fail to PI DATA Archive
                          Noga

                          Is it possible that the reason for my error is that an application using AF SDK can only use 'Trust' and not 'mapping' for remote connecting to PI data archive?

                            • Re: PI AF SDK application connection fail to PI DATA Archive
                              gregor

                              Hello Noga,

                               

                              No, this is not the case. Error -2147220368 translates "Failed to retrieve message(s) from message log." and indicates PI Message Subsystem may not be running on your client.

                              I suggest you to test with a simple console application first and I am in favor of skipping PIServer.Connect() method out completely if there is no good reason to use it. The server object will handle the connection by itself.

                              Please let us know what this simple application does. You only need to adjust the value of piDataArchiveHost string.

                               

                              using System;
                              using OSIsoft.AF.PI;
                              using OSIsoft.AF.Asset;
                              
                              namespace GetSnap
                              {
                                  class Program
                                  {
                                      static void Main(string[] args)
                                      {
                                          string piDataArchiveHost = "GB-PIDA1";
                                          PIServers knownServers = new PIServers();
                                          PIServer piSrv = knownServers[piDataArchiveHost];
                                          PIPoint sinusoid = PIPoint.FindPIPoint(piSrv, "SINUSOID");
                                          AFValue snapshot = sinusoid.CurrentValue();
                                          Console.WriteLine("Point {0} has value {1} at {2}", sinusoid.Name, snapshot.Value, snapshot.Timestamp.LocalTime);
                                          Console.ReadKey();
                                      }
                                  }
                              }
                              
                              1 of 1 people found this helpful
                                • Re: PI AF SDK application connection fail to PI DATA Archive
                                  Noga

                                  Hi Gregor,

                                  When running the code you posted, I get the following error:

                                   

                                  "Unhandeled Exception: System.ArgumentNullException: Value cannot be null.

                                  Parameter name: piServer

                                       at OSIsoft.AF.AFObject.CheckNullOrDeleted<string paramName, AFObject item>

                                       at OSIsoft.AF.PI.PIPoint.FindPIPoint<PIServer piServer, string pointName>

                                       at PI_Points_Request_NET4.program.Main<string[] args) in c:\git\Code Example\PI_Point_Request\Program.cs: line 280

                                    • Re: PI AF SDK application connection fail to PI DATA Archive
                                      gregor

                                      Hello Noga,

                                       

                                      I can reproduce the behavior you describe by specifying an invalid host name for piDataArchiveHost. Did you change the following line?

                                       

                                      string piDataArchiveHost = "GB-PIDA1"; 
                                      
                                        • Re: PI AF SDK application connection fail to PI DATA Archive
                                          Noga

                                          Yes, I changed it to my PI data server name

                                            • Re: PI AF SDK application connection fail to PI DATA Archive
                                              gregor

                                              Hi Noga,

                                               

                                              That's a tough one but I am pretty certain that the cause turns out to be pretty simple in the end like a typo or a missing firewall rule for incoming connection on the PI Data Archive host. Ideally connection issues like yours can be addressed using the 4 eyes principle combined with the support engineers experience in a remote session. I am not giving up yet but would understand if you prefer calling Technical Support for assistance.

                                               

                                              So with PISDKUtility.exe you are able to connect. Is this correct?

                                               

                                              What if you try the following code? Does it list your PI Data Archive host as you've used it?

                                               

                                              using System;
                                              using OSIsoft.AF.PI;
                                              namespace ListKnownServers
                                              {
                                                  class Program
                                                  {
                                                      static void Main(string[] args)
                                                      {
                                                          PIServers knownServers = new PIServers();
                                                          foreach (var ks in knownServers)
                                                          {
                                                              Console.WriteLine(ks.Name);
                                                          }
                                                          Console.ReadKey();
                                                      }
                                                  }
                                              }
                                              
                                • Re: PI AF SDK application connection fail to PI DATA Archive
                                  Eugene Lee

                                  Hi Noga,

                                   

                                  There is a KB article on troubleshooting connectivity that you can refer to as well.

                                  https://techsupport.osisoft.com/Troubleshooting/KB/KB01154/

                                  1 of 1 people found this helpful