Explainer
Why PI AF SDK connection failures are slow to surface
Short answer
While PI Buffer Subsystem is running, a PI AF SDK write is accepted into the local queue and reports success even with the PI Data Archive unreachable. Detect an outage by reading ConnectionInfo on the PIServer object and adding a timed health read of a known point; in the worked example that flags a dead archive within 13 seconds, where the write path alone can stay green for a full shift.
On this page
- Why does a PI AF SDK write succeed while the PI Data Archive is down?
- Which object holds the connection you actually care about?
- What does ConnectionInfo actually prove?
- Why do PIServer events behave differently when PI Buffer Subsystem runs?
- Does shortening the client timeouts make failures surface faster?
- Which AF SDK build should the health check run on?
- How do you build a fail-fast health read into the application?
- How long can buffering hide an archive outage?
- How fast can your application flag a dead archive?
- Questions asked
A green connection light means nothing while PI Buffer Subsystem is in the write path. With buffering registered for the PI Data Archive, the SDK hands each event to the local queue and the write call returns success whether or not the archive machine is reachable, so the write result cannot detect an outage. Fast detection comes from the read side: read ConnectionInfo on the PIServer object your writes actually use, then run a timed read of one known point and flag the screen when that read misses a deadline you set. On the example settings below that flags a dead archive within 13 seconds worst case, while the buffered write path can keep reporting success for more than a day.
Why does a PI AF SDK write succeed while the PI Data Archive is down? #
Because the SDK no longer talks to the archive on that path: once the PI Server is registered for buffering, PI Buffer Subsystem accepts each event into a local queue and returns success immediately, whether or not the archive is reachable.
Buffering holds those events until the connection to the archive can be reestablished or the disk runs out of space. The SDK manages the underlying connection machinery itself, so the transport is not a socket you own and there is nothing at your layer to poll for a broken link. The write path also has failure modes that only show up later: even after the archive comes back, queued writes can sit undelivered, which is its own troubleshooting problem covered in why PI AF SDK writes stall after a PI Server reboot. The conclusion for your indicator design is simple: a completed write is evidence that the queue accepted the event, and nothing more.
Which object holds the connection you actually care about? #
Two servers, two objects: PIServer represents the connection to the PI Data Archive and PISystem represents the connection to the AF Server, and each exposes a ConnectionInfo property you can read in code to see that object's connection status.
They are separate endpoints with separate lifecycles: an AF Server status cannot stand in for an archive status, and the reverse. Use the PIServer instance that performs the application's archive reads and writes, and the PISystem instance only where the application needs AF hierarchy access. You can also inspect connections from the server side: the vendor documentation describes a Connections page in the PI AF Server Properties window where AF server connection details can be viewed, sorted and copied, which is useful when the client application is a packaged product you cannot instrument. Decision: ConnectionInfo on the archive's PIServer object is the first input to any archive indicator, so read it on a schedule rather than only at startup, and stamp each observation with a time so stale status is visible as stale.
What does ConnectionInfo actually prove? #
It reports the SDK object's own view of its connection at the moment you read it, and nothing more: the network can drop immediately after a check, and loss recognition waits on later traffic or on timeout processing before the status moves.
Treat it as one input, not the verdict. Pair each ConnectionInfo observation with the health read below, keep the observation timestamps, and let the display show the age of the last check. A fired connection event is a hint worth logging; the absence of an event is never proof of health, because your code only learns about state changes when the SDK decides to report them.
Why do PIServer events behave differently when PI Buffer Subsystem runs? #
Field reports show the event sequence changes once the PI Server is registered for buffering: disconnect notifications that arrive in one configuration never arrive in the other, so an indicator tuned on an unbuffered test rig can misread a buffered production machine.
The reported difference goes both ways in practice, because some configurations raise more events during an outage and some raise fewer, and there is no published semantic specification for the SDK's event contract. A behavior you observe is therefore neither a bug nor a promise until you have characterized it. Characterize it deliberately: repeat the same controlled outage with buffering running and with buffering stopped, on each SDK and archive version pair you support, and log which events arrive and when; the test recipe is in the questions at the end of this page. Design decision: use events as inputs to the status display, never as the only evidence of health. The health read, not the event stream, is what you act on.
Does shortening the client timeouts make failures surface faster? #
Not for this failure: a buffered write never waits on the archive at all, and the connection and data access timeouts are global client settings, so lowering them reshapes every read, write and list call in the process, not just the one you wanted faster.
The timeouts do belong to you: they are client-side settings, and the vendor documentation points to the PI Connection Manager for adjusting the AF SDK connection timeout, noting the parameter should only be specified under the conditions the vendor gives. The older utility route, PISDKUtility.exe, requires PI SDK, and recent PI AF Client kits ship without PI SDK, so on a current kit that tool may not exist on the machine at all. Decision: tune timeouts when slow operations genuinely block your process, retest the whole application after the change, and never rely on them to detect a buffered outage, because the write was accepted before any timeout could apply.
Which AF SDK build should the health check run on? #
The Rich Data Access build for .NET Framework 4.x from the current PI AF Client kit: the legacy build, built for .NET Framework 3.5, depends on PI SDK, which that kit no longer installs, and only the Rich Data Access build offers AFListData bulk methods.
AF SDK is a .NET library that exposes PI System data to client applications, and PI AF SDK: the native path from a C# application to PI walks through that connection path in detail. With both flavors installed, Visual Studio's reference picker will offer both, so pick deliberately: the reference your project binds decides which connection machinery runs beneath it. Verify the deployed client components on the target machine too, because the absence of PI SDK utilities there is normal on a current kit, and any tooling that expects PI SDK will simply be missing. Decision: reference the .NET Framework 4.x build explicitly, and treat a legacy reference found in an old project as a migration task, not a working baseline.
How do you build a fail-fast health read into the application? #
Run a small timed read of one known point through the same PIServer object your production writes use, on a worker thread, and mark the screen stale the moment the read passes the deadline you set, because that check has to reach the archive to answer at all.
- Pick a point the application's identity reads in normal operation, so a permissions problem cannot fail the check.
- Execute the read outside the operator-interface thread, so a slow request cannot freeze the screen.
- Record the start time, the completion time, the returned status and any exception on every run.
- Compare the result with the latest ConnectionInfo observation and with any connection events you log.
- When the check passes its deadline, flag the display as stale. Your flag is application logic and does not cancel the SDK operation: use whatever cancellation the documented operation provides, and expect the abandoned read to complete eventually.
- Prevent checks from stacking up behind a blocked request, one pending check at a time, and log late completions so a hung network layer leaves a record.
If operators act on this screen for anything with a safety consequence, treat a stale flag as a stop-and-verify condition; a health read is diagnostics, never a safety function. Set the display deadline from the consequence of acting on stale data, and re-derive it when the process changes; the last section below shows the detection arithmetic.
How long can buffering hide an archive outage? #
As long as the queue has disk: on the example load below, a 2 GB queue fed 100 events per second at about 200 bytes per event absorbs roughly 27.8 hours of dead archive, so writes keep reporting success across a full weekend outage.
Worked example, with example inputs you scale to your own line:
- Queue disk allowance: 2 GB, taken as 2,000,000,000 bytes. This is an illustration; you choose the queue size in the buffering configuration on the client machine.
- Event load: 100 events per second at about 200 bytes per event.
Arithmetic:
- Data rate: 100 events/s × 200 bytes/event = 20,000 bytes/s.
- Queue endurance: 2,000,000,000 bytes ÷ 20,000 bytes/s = 100,000 s.
- In hours: 100,000 s ÷ 3,600 s/h ≈ 27.8 h.
At that load the archive can be down for a full day and more before the queue is at risk. A line writing ten times slower stretches the same queue to about 278 hours, roughly 11.6 days, which is why the queue must be sized against your longest credible outage. The queue also keeps accepting events until the disk itself is exhausted, so watch queue occupancy as its own alarm, not just the connection state. When the connection finally returns and the queue drains, the stored values arrive carrying their original event timestamps, not the moment the archive accepted them; why a PI value timestamp is not a receipt time covers what that distinction means for audits and rate calculations.
How fast can your application flag a dead archive? #
With a health check every 10 seconds and a 3 second display deadline, worst-case detection is 10 + 3 = 13 seconds: the outage can begin just after one check returns, and the next read must start and miss its deadline before the screen changes.
Worked detection budget, same example settings: the checker fires every 10 s, and a read still unfinished 3 s after it starts is marked stale. Worst case, the archive dies the instant a successful check completes: the next check starts 10 s later and the screen flags at 13 s. Best case, the archive dies just before a check that fails fast and the flag lands almost immediately. The buffered write path, by contrast, reported success for the entire queue endurance computed above, and an event-driven indicator may never fire at all on a buffered configuration.
Decision, case by case:
- Operator-facing screen or report: run the health read, and keep check interval plus deadline inside the staleness your process tolerates, which is 13 s with the example settings.
- Fire-and-forget write path with no read requirement: a failed write still proves nothing while buffering is on, so monitor queue occupancy and log ConnectionInfo, and accept that detection is as slow as your queue is deep.
- Slow operations hurting other functions: tune the client timeouts through the PI Connection Manager, retest the whole application afterwards, and remember the timeouts are not your outage detector in any case.
Questions asked
What happens to buffered events if the outage outlasts the queue?
The queue keeps accepting events until the disk runs out of space, so a very long outage ends in disk exhaustion on the client machine, not in a visible write error. Size the queue against your longest credible outage and alarm on its occupancy: at the example load the 2 GB queue covered about 27.8 hours, and the fill level shows your remaining margin long before the disk is threatened.
Does PI Buffer Subsystem help reads during an outage?
No. Buffering sits on the write path only. Reads, list queries and event imports still have to reach the archive, and they still fail while the network is down. That asymmetry is what makes the health read a real test: during an outage your timed read fails while your writes keep reporting success, so the two paths together tell you exactly where the failure sits.
Should the indicator watch the AF Server connection too?
Only if the application actually reads the AF hierarchy. PISystem is a separate endpoint from the PI Data Archive, and the AF Server can be reachable while the archive is dead, or the reverse. Give each connection its own health read through its own object, and never let a green AF Server check stand in for a green archive check on an operator screen.
How do I characterize event behavior on the versions I support?
Write one controlled test and keep it in your regression set: run the client against the archive, disconnect the network for a fixed interval with buffering registered, then repeat with buffering stopped, and log which PIServer events arrive, in what order, with what delays. There is no published semantic specification for the SDK's event contract, so behavior is only established by such test cases, repeated at every SDK and archive version upgrade.
Can I detect the outage from outside the application?
A ping only proves the host answers, and a buffered client sits on a healthy host through a dead archive. Monitor the archive service port itself, 5450 in the standard installation, and where possible run a real read with the same credentials your application uses. Host reachability is necessary evidence, never sufficient.