Troubleshooting
Why PI AF SDK writes stall after a PI Server reboot
Short answer
After a PI Server restart, AF SDK writes can return no errors while nothing lands in the archive, because PiServer.ConnectionInfo.IsConnected keeps reporting the old connection state and snapshot errors go unchecked. Gate recovery on operation-level errors instead, and preconfigure PI Buffer Subsystem so BufferIfPossible actually queues events through the outage window.
On this page
- First, confirm what actually stalled
- Why IsConnected stays true through the restart
- Treat snapshot errors as the disconnect signal
- An empty error collection is not delivery confirmation
- Worked example: events at stake in one restart window
- Configure and verify the buffer before the next restart
- The decisions
- Questions asked
After a scheduled PI Server restart, your AF SDK service can log successful writes, show no errors, and still deliver nothing to the archive — and restarting the service brings the stream back. Two independent faults produce that pattern, and the write call hides both. PiServer.ConnectionInfo.IsConnected keeps reporting the state of the last successful connection, so the restart never registers as a disconnect; snapshot reads return default values together with RPC Resolver is Off-Line errors that the code ignores. And AFBufferOption.BufferIfPossible only selects the buffering option for a single call: if PI Buffer Subsystem is not preconfigured on the writer machine, nothing queues and nothing flushes. Gate recovery on operation-level errors, configure the buffer through Buffering Manager, and verify both before the next restart window.
First, confirm what actually stalled #
Work from one known point:
- Pick a point your service updates every cycle and read its current value and timestamp straight from the archive.
- Compare that timestamp against the service's own submission log for the same point and cycle.
- If the archive timestamp advances normally, your writer is fine and the fault is downstream; investigate the consumer instead.
- If the timestamp is stuck while the service keeps logging submissions, you have the stall described here, and the checks below apply.
The reported case fits this shape exactly: a Windows service built on AF client 2016 R2 SP1, build 2.9.1.8106, writing to a PI Server and Data Archive at 2.8.5.7759, with the server VM restarted once a week. UpdateValuesAsync with AFBufferOption.BufferIfPossible returned an empty error collection throughout the outage, and new values appeared only after the service itself was restarted. Record those versions in your incident notes, but treat this as a logic and configuration failure, not a version defect — nothing in the behavior pinned it to a build.
Why IsConnected stays true through the restart #
PiServer.ConnectionInfo.IsConnected reports the state of the last time you connected. If the connection drops, the property keeps its old value — in the reported case it stayed true for the whole outage. It is a cached state, not a live probe, so a remote restart invalidates the communication path before the property notices. A recovery loop that waits for this property to flip will wait forever, because it never does.
Use it as one input, never as the gate. The gate is the outcome of an actual operation.
Treat snapshot errors as the disconnect signal #
The decisive observation: snapshot reads returned default values while the read results carried RPC Resolver is Off-Line, and the connection property still read true. The defaults are not measurements — they are what the list returns when the operation fails, and the errors attached to the returned PiPointList say so.
Work the read like this:
- Record the connection property's value while the archive is unavailable, so you know what it reports during an outage.
- Execute the normal snapshot read and inspect the operation-level and point-level errors attached to the returned list.
- Map every failed result to its point and acquisition attempt, and keep its default value out of calculations, change detection and write preparation.
- On a communication failure, trigger the application's recovery path even though the property still reads true.
The reported fix was to disconnect and reconnect when this error pattern appears. If your service uses implicit connections, keep them — implicit connection handling does not conflict with an explicit recovery branch that fires on operation errors. Validate the branch against one scheduled restart before trusting it.
An empty error collection is not delivery confirmation #
Even after the server answers again, the write call's return value proves less than it seems. For writes routed through PI Buffer Subsystem, error feedback from the PI Data Archive cannot be returned to the caller — a documented limitation of the buffered path. An empty collection from UpdateValuesAsync tells you the submission was accepted somewhere in the path, not that an event reached the archive with your value and timestamp.
Close the loop differently: confirm the submitted tag, value and timestamp by reading the point back from the archive. The timestamp you get back is not the moment you submitted — Why a PI value timestamp is not a receipt time covers that distinction — so match on tag and value first, then on the event time you assigned. For buffered writes, use the buffer's own diagnostics plus readback as the delivery check, never the error collection.
Worked example: events at stake in one restart window #
Example inputs, sized for a small line: 25 points, each written at 2 events per second, with the restart window taking 10 minutes.
- 10 min × 60 s/min = 600 s of outage.
- 600 s × 2 events/s = 1,200 events for one point.
- 1,200 events × 25 points = 30,000 events submitted during that window.
With the buffer subsystem off, BufferIfPossible has nothing to queue through, so those 30,000 events reach the archive only if the application itself retained and replays them. Without that history recovery they are gone, and each weekly restart repeats the loss. That number is the acceptance criterion for the test: after you configure the buffer, the next scheduled restart should end with 30,000 events (for these example inputs) present in the archive, confirmed by readback rather than by the absence of errors.
One caution: a deliberate restart test on a production archive lands on every downstream consumer at once — do it inside the window you already publish.
Configure and verify the buffer before the next restart #
Buffering is configured with Buffering Manager, which you open from the Tools menu in PI System Explorer (PSE) on the machine your service runs on; the buffer report there is the first health check. The command-line route is pibufss -cfg: when the destination is reachable, a healthy buffer reports a SendingData state. If that state is absent, fix the subsystem configuration and its reported faults before claiming buffered delivery. PI Buffer Subsystem 4.x is the recommended generation — new installations are documented from version 4.3 onward.
Then confirm your points actually use it. Dump one point's snapshot with piartool -sd pumptemp01 (pumptemp01 is an example tag): the output identifies the machine the data comes from, and the buffer registration id appears under the Compressed Event section. No registration id there means that point bypasses the buffer, however healthy the service looks. Test both checks before an outage, not during one — buffering state and point registration are verifiable on a normal day.
PI Buffer Subsystem runs on the writer machine itself, next to your AF SDK process. If that writer is currently a shared workstation and you are specifying a dedicated data-collection host for it, this is the moment to choose a fanless mini PC built for continuous service in the cabinet.
The decisions #
- Snapshot reads return errors while the connection property reads true: treat the connection as down, run the disconnect-and-reconnect branch, and never process the default values that arrived with the errors.
- Writes must survive a server restart: preconfigure PI Buffer Subsystem with Buffering Manager on the writer machine, verify
SendingDatawithpibufss -cfg, and verify point registration with a snapshot dump — before the next scheduled restart. - Buffering cannot be configured and the application has no history recovery: the application itself must retain and replay the events it submits during outages, or accept the loss;
BufferIfPossibledoes not cover it. - A service restart brings the stream back: that is a workaround, not a fix — it resumes current writes and recovers nothing from the outage window.
Buffered outage recovery is one pattern across the plant floor: how S7-1500 DataLog buffering recovers a WinCC V7.5 SCADA outage shows the same retention logic on a different writer. The reconnect half is the same discipline as Reconnect an edge PC to SQL Server after connection loss. Build both into the service once, and the weekly restart becomes a non-event.
Questions asked
Does BufferIfPossible turn buffering on by itself?
No. It only selects the buffering option for one write call. Successful buffered delivery requires PI Buffer Subsystem to be preconfigured with Buffering Manager on the machine that makes the writes. In the reported case the subsystem was simply never turned on, so the option had nothing to route through and no events were queued during the restart window.
Why did the write call return no errors during the outage?
During the restart itself there was no server to return errors from. Treat an empty error collection as proof of submission only, and confirm each tag, value and timestamp by reading the point back from the archive.
How do I verify my points are buffered before the next restart?
Check the subsystem first: run pibufss -cfg and look for a SendingData state while the server is reachable. Then dump one point's snapshot with piartool -sd and look for the buffer registration id under the Compressed Event section. If the id is missing, that point bypasses the buffer. Run both checks on a normal day, not during the outage.
Does restarting the service fix the problem for good?
No. The restart rebuilds the application's connection state, so current writes resume, but events generated during the outage were never queued while the buffer subsystem was off and are lost unless the application kept its own copies. The durable fix is a recovery branch driven by operation-level errors plus a configured and verified buffer subsystem on the writer machine.