Ashok_NK

Connect Guidance / Best Practise, Intermittent 'Insufficient privilege to access the PI Server'

Discussion created by Ashok_NK on Oct 13, 2013
Latest reply on Oct 14, 2013 by Ashok_NK

Hi

 

I'm building a Web API in which actions typically connect to AF to get data.

 

Pseudocode:

 

Invoke Web API
    Connect(networkCredentials)
    AF SDK to get data, e.g. AFAttribute.Data.GetValues(...
    return data
    Disconnect 

 

I'm observing intermittent connection problems with the current approach, 2/7 calls fail to get data. Connect itself doesn't seem to be failing, but later on when retrieving data, error is:

 

OSIsoft.AF.PI.PIConnectionException: Insufficient privilege to access the PI Server. ---> OSIsoft.PI.Net.PIException: [-10407] No Access - Secure Object

 

I've come across a few references that elude to NOT explicitly disconnecting AF Server & PI System connections. e.g.

 

Connecting/Disconnecting AF Server is typically not recommended for short lived calls anyway, for example within a web service, as there is a significant initialization cost per connection.  AF will reuse connections as long as the AF Connection itself has not been GC'd.

 

http://vcampus.osisoft.com/discussion_hall/development_with_osisoft_sdks/f/28/t/3615.aspx

 

AF doco implies you should disconnect when finished with a connection :) Should I NOT explicitly call Disconnect? Any other advice on troubleshooting this problem?

 

Thanks

Outcomes