Database 'somedatabase' has been disconnected.

Discussion created by IKovalchuk on Sep 30, 2014
Latest reply on Nov 26, 2014 by David Hearn

Hi !


AF Server Version


AF SDK Version


 I have some troubles with AF servers communication. It starts on the AF SDK 2012 R2. At this period I recieve exceptions about invalid credentials time to time. But credentials was same - for first connection and later reconnections


I decide to update SDK to 2014 and then to 2014 R2. Problems with credentials disappear. But now I have two exceptions, also time to time.


Sometimes (too often to ignore) I got Communication exception or Invalid operation exception, but I think this is two faces of one problem.


Network is good, af servers is up, but I get this:

[CLIENT 3] Invalid operation. Error:

System.InvalidOperationException: Database 'somedatabase' has been disconnected. This is caused by using an object from a database after calling PISystem.Disconnect.
   at OSIsoft.AF.AFDatabase.CheckDisconnected(AFObject item)
   at OSIsoft.AF.AFObject.GetProxy(Boolean switchToPrimary)
   at OSIsoft.AF.Asset.AFElements.LoadObjects(Int32 page, Boolean fullReload)
   at OSIsoft.AF.AFCollection`1.Load(Boolean force)
   at OSIsoft.AF.AFCollection`1.<GetEnumerator>d__1.MoveNext()
   at PIEnd.PIAFClient.FindElementByItemId(AFElement root, Guid property, Guid resource) in c:\est-astu\PIEnd\AFClient.cs:line 1156
   at PIEnd.PIAFClient.ProcessItemBrowserGetPathnamesRequest(String[] itemIdsStr) in c:\est-astu\PIEnd\AFClient.cs:line 544
   at PIEnd.PipeClientHandle.ParseMessage(String message) in c:\est-astu\PIEnd\PipeClientHandle.cs:line 408
   at PIEnd.PipeClientHandle.Serve() in c:\est-astu\PIEnd\PipeClientHandle.cs:line 97

This happens then I iterate througth AFElements of AFDatabase or get elements attributes. Database unexpectedly got disconnected, or communication to AF server broken. I need to reconnect in an infinite loop (with i.e. 5 sec interval), take AFDatabase, and continue iterations.


Text of  second exception will be attached later - not have it for this moment.


I could ignore this, but I can't. It is often happens that client thread can't reconnect to server for a long time with same exceptions. At the same time other client threads of process work with AF server w/o problems.


If this is a normal behavior and I need take it in account, so no questions. If not, what can I do?


Little explain - i normally have from 4 to 15 client threads with own connected PISystem instances. In each thread I have two PISystem instances for two different AF servers, AFServers located on each own computers, have different addresses. But exceptions happens with both. Thanks.