Configuration
Thresh is configured through ThreshOptions in AddThresh(...).
Example
services.AddThresh(options =>
{
options.AcceptSelfSignedCertificates = true;
options.WsAcceptSelfSignedCertificates = true;
options.HttpTimeout = TimeSpan.FromSeconds(10);
options.MaxRetryAttempts = 3;
options.CircuitBreakDuration = TimeSpan.FromSeconds(10);
options.CircuitSamplingDuration = TimeSpan.FromSeconds(30);
options.CircuitMinimumThroughput = 20;
options.CircuitFailureRatio = 0.5;
options.BaseRetryDelay = TimeSpan.FromSeconds(1);
options.WsMaxBackoff = TimeSpan.FromSeconds(10);
options.WsSilenceThreshold = TimeSpan.FromSeconds(45);
});
Option reference
Certificate handling
AcceptSelfSignedCertificates
Enables loopback-scoped acceptance for local LCU HTTPS communication.WsAcceptSelfSignedCertificates
Enables equivalent handling for the LCU WebSocket connection.
HTTP resilience and timeout
HttpTimeout
Per-request timeout applied to the configuredHttpClient.MaxRetryAttempts
Number of retry attempts used by Polly for transient failures.CircuitBreakDuration
How long the circuit remains open once tripped.CircuitSamplingDuration
Evaluation window for failure ratio calculation.CircuitMinimumThroughput
Minimum number of requests before circuit evaluation is considered meaningful.CircuitFailureRatio
Failure threshold (0..1) that opens the circuit.
WebSocket reconnect behavior
BaseRetryDelay
Base reconnect delay used for exponential backoff.WsMaxBackoff
Upper bound for reconnect delay.WsSilenceThreshold
If no messages are received for this duration, a reconnect is forced.
Practical tuning tips
- Start with defaults, then tune only when required by observed behavior.
- Increase
HttpTimeoutfor slower local machines or heavy startup phases. - Raise
WsSilenceThresholdif your event traffic is sparse. - Keep retries conservative to avoid hiding persistent errors.