10 Replies Latest reply on May 16, 2018 9:48 AM by gregor

    How can I change the timeout settings in my Python script?

    Philipp_Gattig

      PIConnectionException: [-10722] PINET: Timeout on PI RPC or System Call.

         at OSIsoft.AF.PI.PIException.ConvertAndThrowException(PIServer piServer, Exception ex, String message)

         at OSIsoft.AF.PI.PIServer.RemoteConnect(AFConnectionPreference preference, NetworkCredential credential, PIAuthenticationMode authenticationMode)

         at OSIsoft.AF.PI.PIServer.InternalConnect(Int32 numRetries, IWin32Window owner, AFConnectionPreference preference, NetworkCredential credential, PIAuthenticationMode authenticationMode, Boolean checkConnectingAsSameUser)

         at OSIsoft.AF.PI.PIServer.AutoConnect(Boolean allowDirectConnect, Boolean force)

         at OSIsoft.AF.PI.PIServer.Connect(Boolean force)

       

      Do I have to change my timeout settings? Or Do I have to authenticate myself manually? If I manually start PI Coresight through the website, the startup process will take about 20 seconds.

        • Re: How can I change the timeout settings in my Python script?
          gregor

          Hello Philipp,

           

          There is usually a reason for a timeout. As mentioned within KB00232 - -10722: RPC Timeout on PI RPC or System Call one needs to know the context. If you like to receive any guidance on how to avoid the timeout, please share your script.

          1 of 1 people found this helpful
          • Re: How can I change the timeout settings in my Python script?
            Philipp_Gattig

            Hello Gregor,

             

            here is my Script. The error appears about 3 seconds after the start of the script. I'm grateful for any idea how to solve it

             

            import sys 
            import clr 

            sys.path.append(r'C:\Program Files (x86)\PIPC\AF\PublicAssemblies\4.0')   
            clr.AddReference('OSIsoft.AFSDK') 
             
            from OSIsoft.AF import * 
            from OSIsoft.AF.PI import * 
            from OSIsoft.AF.Asset import * 
            from OSIsoft.AF.Data import * 
            from OSIsoft.AF.Time import * 
            from OSIsoft.AF.UnitsOfMeasure import * 

             

            piServers = PIServers() 
            piServer = piServers["INGPIMSAF"] 

             

            piServer.Connect(False)
             
            pt = PIPoint.FindPIPoint(piServer, "9901.Respimat\KV\BM3\Drehzahl|Schneckendrehzahl_Extruder_1") 
            name = pt.Name.lower() 


            print('\nShowing PI Tag CurrentValue from {0}'.format(name)) 
            current_value = pt.CurrentValue() 
            print( '{0}\'s Current Value: {1}'.format(name, current_value.Value))

            -------------------------------------------

             

            PIConnectionException: [-10722] PINET: Timeout on PI RPC or System Call.

               at OSIsoft.AF.PI.PIException.ConvertAndThrowException(PIServer piServer, Exception ex, String message)

               at OSIsoft.AF.PI.PIServer.RemoteConnect(AFConnectionPreference preference, NetworkCredential credential, PIAuthenticationMode authenticationMode)

               at OSIsoft.AF.PI.PIServer.InternalConnect(Int32 numRetries, IWin32Window owner, AFConnectionPreference preference, NetworkCredential credential, PIAuthenticationMode authenticationMode, Boolean checkConnectingAsSameUser)

               at OSIsoft.AF.PI.PIServer.AutoConnect(Boolean allowDirectConnect, Boolean force)

               at OSIsoft.AF.PI.PIServer.Connect(Boolean force)

              • Re: How can I change the timeout settings in my Python script?
                gregor

                Hi Philipp,

                 

                I am planning to try your script but what I see at first glance is that you are attempting to read the current value of an AF Attribute but you use PIServer instead of PISystem as the server object.

                 

                Can you please replace PIServers() with PISystems() and PIServer["INGPIMSAF"] with PISystem["INGPIMSAF"]?

                You don't need to call the Connect method explicitly because the server object will handle the connection. Instead of the PIPoint.FindPIPoint object, please use AFAttribute.FindAttribute Method. AFAttribute.GetValue() method should be sufficient to get the snapshot (current value). Please see the example underneath the documentation of AFAttribute Class. You can easily skip over creating an Element and an Attribute.

                1 of 1 people found this helpful
                • Re: How can I change the timeout settings in my Python script?
                  gregor

                  Hi Philipp,

                   

                  I have created 2 examples, one which shows how to get the current value for a PI Point and one which does the same but with for an AF Attribute.

                   

                  # AFSDK-GetSnap.py
                  
                  import sys 
                  import clr 
                  
                  sys.path.append(r'C:\Program Files (x86)\PIPC\AF\PublicAssemblies\4.0')   
                  clr.AddReference('OSIsoft.AFSDK')
                  
                  from OSIsoft.AF.PI import * 
                  from OSIsoft.AF.Asset import * 
                  
                  knownServers = PIServers()
                  piSrv = knownServers["GB-PIDA1"]
                  
                  sinusoid = PIPoint.FindPIPoint(piSrv, "SINUSOID")
                  
                  snapshot = sinusoid.CurrentValue()
                  
                  print('Point {0} has value {1} at {2}'.format(sinusoid.Name, snapshot.Value, snapshot.Timestamp.LocalTime))
                  

                   

                  Because Visual Studio intellisense identifies AFAttribute.GetValue() as deprecated, I've used AFAttribute.Data.RecordedValue() instead.

                   

                  # AFSDK-GetEASnap.py
                  
                  import sys 
                  import clr 
                  
                  sys.path.append(r'C:\Program Files (x86)\PIPC\AF\PublicAssemblies\4.0')   
                  clr.AddReference('OSIsoft.AFSDK')
                  
                  from OSIsoft.AF import *
                  from OSIsoft.AF.Asset import * 
                  from OSIsoft.AF.Data import * 
                  from OSIsoft.AF.Time import * 
                  
                  knownSystems = PISystems()
                  piSys = knownSystems["GB-PIAF"]
                  
                  B210_FuelGasFlow = AFAttribute.FindAttribute("\\NuGreen\\NuGreen\\Houston\\Cracking Process\\Equipment\\B-210|Fuel Gas Flow", piSys)
                  
                  nowTime = AFTime.NowInWholeSeconds
                  snapshot = B210_FuelGasFlow.Data.RecordedValue(nowTime, AFRetrievalMode.AtOrBefore, None)
                  
                  print('Attribute {0} has value {1} at {2}'.format(B210_FuelGasFlow.Name, snapshot.Value, snapshot.Timestamp.LocalTime))
                  

                   

                  Please let us know if you have any questions.

                  1 of 1 people found this helpful