AnsweredAssumed Answered

Problems with PIPoint.LoadAttributes after connection was closed by PI Server

Question asked by eignert on Jun 2, 2015
Latest reply on Jun 2, 2015 by dng

Hi everyone,

 

I'm currently experiencing a strange problem that I've traced down to the following situation:

 

I have developed a windows service that loads data from a datasource and writes the data to various PI Servers. Sometimes there's a lot of data at one time, sometimes there is no data for a long time.

PI access is exclusively using the AFSDK and I don't open the connection to the PI Server(s) explicitly. I'm also not closing the connection b/c we'd then have a huge amount of connects and disconnects when there's a lot of data to write.

But sometimes the existing connection is closed by the PI Server because it was idle too long (as defined in the Tuning Parameters). Then the next call gives me an exception that I can catch. All further calls for other tags are then working fine b/c the connection is automatically reestablished after the AFSDK notices the disconnection and threw the exception. But when I execute the LoadAttributes() method for the tag that initially generated the exception the LoadAttributes() call is never returning and blocking the whole data processing. I also don't get an exception but I definitely know from my logging that it's the LoadAttributes call that doesn't return.

 

Recreating this issue is pretty simple:

 

 

try
{
PIServer server = new PIServers()["piserver"];
PIPoint point = PIPoint.FindPIPoint(server, "sinusoid");
if (point != null)
{
point.LoadAttributes("pointsource");
Console.WriteLine(point.GetAttribute("pointsource"));
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}

 

Execute this code once and leave the application open. Wait for the connection to time out (best would be to have a test PI Server where you Change the MaxIdleTime for a connection to sth. like 60 seconds for testing so that you don't have to wait too long) and execute it one more time and you'll get a PIConnectionException -10723 "PINET: No Connection".

When you then execute it a third time the call of LoadAttributes() hangs and doesn't return.

 

Could it be that this has somehow to do with a cached PIPoint object that was created on the "old" connection that has been closed by the server?

The only way for me to get a around this now was to add explicit calls to connect / disconnect methods for the Connections but as I wrote this is sth. I would like to get rid off b/c of the amount of connects / reconnects.

 

Any suggestions / ideas what the cause might be and how I could get around this?

Outcomes