Events
Three PSR-14 events emitted around each HTTPS POST — observe traffic, time it, or audit failures without subclassing the transport.
Pass a Psr\EventDispatcher\EventDispatcherInterface to the
HttpsTransport constructor and three events fire around each POST.
When the dispatcher argument is null nothing is constructed —
zero overhead.
All event classes live under
PhpOpcua\Client\ExtTransportHttps\Event\, are final readonly,
and carry only fields that are safe to log (no request body).
HttpsRequestSent
final readonly class HttpsRequestSent
{
public function __construct(
public string $url,
public string $contentType,
public int $bodyLength,
);
}
Dispatched just before the POST hits the wire. Useful for tracing, metrics, sampling.
HttpsResponseReceived
final readonly class HttpsResponseReceived
{
public function __construct(
public string $url,
public int $statusCode,
public int $bodyLength,
);
}
Dispatched after a 2xx response, before the encoding strategy decodes
the body. Pair it with HttpsRequestSent for round-trip timing.
HttpsRequestFailed
final readonly class HttpsRequestFailed
{
public function __construct(
public string $url,
public int $statusCode, // 0 = network-level failure
public Throwable $cause, // the originating exception
);
}
Dispatched in two cases:
statusCode === 0— the HTTP client raisedHttpsRequestException(DNS, connect, TLS, read timeout).causeis theHttpsRequestExceptionitself.statusCode > 0— the server returned a non-2xx.causeis theHttpsStatusExceptioncarryingresponseBodyfor triage.
The transport re-throws after dispatching, so a handler can audit and let the exception flow to the application code naturally.
Ordering guarantees
For one transport->send():
| Outcome | Events |
|---|---|
| 2xx | HttpsRequestSent → HttpsResponseReceived |
| Non-2xx | HttpsRequestSent → HttpsRequestFailed (statusCode > 0) |
| Network error | HttpsRequestSent → HttpsRequestFailed (statusCode = 0) |
| HEL frame (fake ACK locally) | no events — no HTTP traffic generated |
Dispatcher errors are swallowed
If your dispatcher throws, the transport logs a WARNING and continues —
event delivery never breaks the OPC UA round-trip.