Diagnostics: surface upstream WS close reason + break the null-spin loop
The Pi journal showed 170 000 'upstream silent NxN' messages within one second — i.e. ReceiveJsonAsync was returning null in zero time, so the upstream WS to OpenAI was closed. The relay was spinning until idle watchdog (30 s) fired. Add IRealtimeUpstream.IsClosed + CloseReason, populated by OpenAIRealtimeUpstream from the close status / WS exception, and have PumpAsync stop on close and forward error code=upstream_closed message=close status=<X> desc=<Y> to the device. Closes the spin AND gives us the OpenAI close reason.
This commit is contained in:
@@ -6,4 +6,8 @@ public interface IRealtimeUpstream : IAsyncDisposable
|
||||
{
|
||||
Task SendJsonAsync(JsonObject envelope, CancellationToken ct);
|
||||
Task<JsonObject?> ReceiveJsonAsync(CancellationToken ct);
|
||||
// Once a receive returns null because the WebSocket transitioned out of
|
||||
// the Open state, these surface why. Both stay null until that happens.
|
||||
bool IsClosed { get; }
|
||||
string? CloseReason { get; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user