mgth/LittleBigMouse · error · InvalidOperationException
The VIDAA connection is not open.
Error message
The VIDAA connection is not open.
What it means
The private Open() accessor returns the current connection object but throws InvalidOperationException if _connection is null, i.e. the session is not currently open. PublishAsync/SubscribeAsync/UnsubscribeAsync rely on it to guarantee they never operate on a closed connection.
Solutions
- Call EnsureOpenAsync(ct) (or await ReopenAsync) before any publish/subscribe call
- Check the Connected property before publishing and reopen when false
- Wrap publishes in try/catch on InvalidOperationException and reopen+retry once
- Investigate why the connection dropped (device standby, network) if it recurs
Example fix
// before session.PublishAsync(topic, payload, ct); // may throw if closed // after await session.EnsureOpenAsync(ct); await session.PublishAsync(topic, payload, ct);
Defensive patterns
Strategy: retry
Validate before calling
if (!session.Connected)
await session.EnsureOpenAsync(ct);
await session.PublishAsync(topic, payload, ct); Type guard
bool CanPublish(IVidaaSession session) => session.Connected;
Try / catch
try
{
await session.PublishAsync(topic, payload, ct);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("VIDAA connection is not open"))
{
await session.ReopenAsync(ct);
await session.PublishAsync(topic, payload, ct);
} Prevention
- Serialize publishes through a single method that opens the session on demand
- Subscribe to MessageReceived/connection-lost events to reopen proactively
- Avoid publishing while the device may be in standby; wake/check first
- Guard against concurrent publish/reconnect races with a semaphore
When it happens
Trigger: Calling PublishAsync, SubscribeAsync or UnsubscribeAsync on a VidaaSession before EnsureOpenAsync succeeded, or after CloseAsync/the connection dropped (device offline, socket closed, exception in the message loop).
Common situations: Fire-and-forget publish after a network blip killed the connection; subscribing to response topics before opening; a background worker keeps publishing while the UI closed the session; race between reconnect and publish.
Understand the failure class
Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.
Related errors
- The VIDAA connection is not open.
- Pair this Hisense VIDAA device first.
- VIDAA rejected every authentication variant for protocol
- Enter a platform action name containing only letters…
- Associate a Hisense VIDAA projector first.
AI-assisted analysis of mgth/LittleBigMouse@7a42f01d47 (2026-09-16).
Data as JSON: /api/errors/8eac6296f15fcc5e.
Report an issue: GitHub.
Appendix: source
Thrown at LittleBigMouse.Plugins/LittleBigMouse.Plugin.Vcp.Avalonia/HisenseVidaa/VidaaSession.cs:111
connection.MessageReceived -= Dispatch;
await connection.DisposeAsync().ConfigureAwait(false);
}
/// <summary>
/// Tells a session the broker dropped from a command the device refused, so that only the
/// former is worth sending again.
/// </summary>
public static bool IsConnectionFailure(Exception exception)
=> exception is IOException or SocketException or ObjectDisposedException;
async Task ReopenAsync(CancellationToken cancellationToken)
{
await CloseAsync().ConfigureAwait(false);
await EnsureOpenAsync(cancellationToken).ConfigureAwait(false);
}
IVidaaConnection Open()
=> _connection ?? throw new InvalidOperationException("The VIDAA connection is not open.");
void Dispatch(string topic, byte[] payload, bool retained)
=> MessageReceived?.Invoke(topic, payload, retained);
}
View on GitHub (pinned to 7a42f01d47)