Timeout problem accessing AF

Discussion created by ineoscgn on Nov 14, 2014
Latest reply on Nov 19, 2014 by ineoscgn


I am experiencing some problems with a C# command line program that is accessing AF and PI. The overall structure is (very simplified) as follows:

1. Connect to a PI System and PI Server

2. Using the following statement to find AF elements:

AFNamedCollectionList<AFElement> ksInterfaces;
ksInterfaces = AFElement.FindElements(monitoringDB, null, ksServiceTemplate, AFSearchField.Template, true, AFSortField.Name, AFSortOrder.Ascending, 5000);

3. Doing something for each element in the list (searching points in PI server, creating subelements of "ksInterfaces", setting attributes, finding some subelements, ...) which takes some time (about 30 minutes).

4. Checking in the changes:


5. Again doing something for each element in ksInterfaces.

6.  Checking in the changes again.

The program does exactly what it should do, until point 5. As soon as I am going to access any element of "ksInterfaces" again, for example

foreach (AFElement ksInterface in ksInterfaces)

I get the following exception (sorry, a part of it is in German - I replaced the name of our AF server with [afserver]):

Unbehandelte Ausnahme: System.TimeoutException: Dieser an net.tcp://[afserver]:5457/

AFServer/Service gesendete Anforderungsvorgang hat innerhalb des konfigurierten 

Zeitlimits (00:05:00) keine Antwort empfangen. Der für diesen Vorgang zugewiesene 

Zeitraum war möglicherweise ein Teil eines längeren Timeouts. Mögliche Ursachen: 

Der Dienst verarbeitet den Vorgang noch, oder der Dienst konnte keine Antwortnachricht 

senden. Erwägen Sie, das Zeitlimit für den Vorgang zu erhöhen (indem Sie den Kanal/Proxy 

in IContextChannel umwandeln und die OperationTimeout-Eigenschaft festlegen), und stellen

Sie sicher, dass der Dienst eine Verbindung mit dem Client herstellen kann.

Server stack trace:
   bei System.ServiceModel.Dispatcher.DuplexChannelBinder.Request(Message messag
e, TimeSpan timeout)
   bei System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean o
neway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan ti
   bei System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCal
lMessage methodCall, ProxyOperationRuntime operation)
   bei System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
   bei System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage re
qMsg, IMessage retMsg)
   bei System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgD
ata, Int32 type)
   bei IAFServer.FindElements(dcServerError& err, Int32 clientVersion, dcObjectI
dentity rootObject, Boolean recurseHierarchy, Byte elementClass, DateTime queryD
ate, String queryString, Int32 fields, dcQueryOptions query)
   bei OSIsoft.AF.Support.AFSerialProxy.FindElements(AFDatabase database, AFObje
ct searchRoot, Boolean modelsOnly, String query, AFSearchField field, Boolean re
cursive, Int32 startIndex, AFSortField sortField, AFSortOrder sortOrder, Int32 m
axCount, Boolean returnTotalCount, Int32& totalCount)
   bei OSIsoft.AF.Asset.AFElement.FindElementsImpl(AFDatabase database, AFElemen
t searchRoot, String query, AFSearchField field, Boolean searchFullHierarchy, AF
SortField sortField, AFSortOrder sortOrder, Int32 startIndex, Int32 maxCount, Bo
olean returnTotalCount, Int32& totalCount)
   bei OSIsoft.AF.Asset.AFElement.FindElements(AFDatabase database, AFElement se
archRoot, String query, AFSearchField field, Boolean searchFullHierarchy, AFSort
Field sortField, AFSortOrder sortOrder, Int32 maxCount)
   bei InterfaceReadInfo.Program.Main(String[] args) in ..path..\Program.cs:Zeile 403.
Connection to pinetmgr lost.

To me, this message indicates that some connection settings might need to be changed, because there is a timeout.

I already tried to

  • reconnect to AF before point 5
  • searching the elements again, which works (!), but the access to any element to the list throws the exception again

Is there any idea what is going wrong here? What strikes me is that the first acccess to any element of "ksInterfaces" works well, while the second using exactly the same syntax goes wrong.

Thank you,