I'm building a Web API in which actions typically connect to AF to get data.
Invoke Web API
AF SDK to get data, e.g. AFAttribute.Data.GetValues(...
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.
AF doco implies you should disconnect when finished with a connection :) Should I NOT explicitly call Disconnect? Any other advice on troubleshooting this problem?