Cause: the client-side PerEndpointConnectTimeout (3 s), not opc-plc. The validate:null case is the first test the assembly runs, so it pays the cold-process cost of the first Basic256Sha256 connect: loading the fresh throwaway certificate, validating the server's, and the asymmetric handshake. In the G2 full-solution run that local work used up the budget. The opc-plc log at 13:13:50-53Z shows the discovery channel closing at 50.709, then nothing from the client for 3 s, then OpenSecureChannel answered at 53.775 and the client closing the channel 48 ms later. The SDK reports a wait cancelled by that budget as BadRequestInterrupted. opc-plc auto-accepted the certificate (--aa, "Trusting certificate ... command line option") with no reject and no store round-trip. - Driver: a per-endpoint budget expiry now surfaces as TimeoutException naming PerEndpointConnectTimeout instead of BadRequestInterrupted or a bare TaskCanceledException. There is no behaviour change. Unit test added against a silent TCP listener. - Test: the ServerHostNameValidationTests secure options use a 15 s budget, the same as the browser integration tests' 10 s. Connect latency is not what these tests check. - docs/drivers/OpcUaClient.md: documents what the budget covers.
This commit is contained in:
+6
@@ -35,6 +35,12 @@ public sealed class ServerHostNameValidationTests(OpcPlcFixture sim) : IDisposab
|
||||
SecurityMode = OpcUaSecurityMode.SignAndEncrypt,
|
||||
AutoAcceptCertificates = false,
|
||||
CertificateValidation = new OpcUaCertificateValidationOptions { ValidateServerHostName = validateHostName },
|
||||
// Gitea #910: the default 3 s per-endpoint budget covers client-side work too — loading the fresh throwaway
|
||||
// certificate, validating the server's, the first Basic256Sha256 handshake in a cold test process. The first
|
||||
// test in this assembly (the validate:null case) paid that cold cost, and in the full-solution run it ran out:
|
||||
// opc-plc answered OpenSecureChannel at once, but the client reached it only after 3 s of local work and
|
||||
// cancelled 48 ms later (BadRequestInterrupted). What is under test is the host check, not connect latency.
|
||||
PerEndpointConnectTimeout = TimeSpan.FromSeconds(15),
|
||||
};
|
||||
|
||||
/// <summary>Trust the fixture's server certificate (as advertised on its secure endpoint) in the throwaway PKI.</summary>
|
||||
|
||||
@@ -83,4 +83,30 @@ public sealed class OpcUaClientFailoverTests
|
||||
ex.Message.ShouldContain("127.0.0.1:3");
|
||||
drv.GetHealth().State.ShouldBe(DriverState.Faulted);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gitea #910: an endpoint that accepts TCP but never answers runs out the per-endpoint budget. The SDK reports
|
||||
/// that as BadRequestInterrupted / a bare cancellation; the failover aggregate must name the budget instead.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async Task A_per_endpoint_budget_expiry_is_reported_as_that_budget()
|
||||
{
|
||||
using var silent = new System.Net.Sockets.TcpListener(System.Net.IPAddress.Loopback, 0);
|
||||
silent.Start(); // accepts (kernel backlog) but never reads or replies
|
||||
var port = ((System.Net.IPEndPoint)silent.LocalEndpoint).Port;
|
||||
var opts = new OpcUaClientDriverOptions
|
||||
{
|
||||
EndpointUrl = $"opc.tcp://127.0.0.1:{port}",
|
||||
PerEndpointConnectTimeout = TimeSpan.FromMilliseconds(400),
|
||||
Timeout = TimeSpan.FromSeconds(30),
|
||||
AutoAcceptCertificates = true,
|
||||
};
|
||||
using var drv = new OpcUaClientDriver(opts, "opcua-budget");
|
||||
|
||||
var ex = await Should.ThrowAsync<AggregateException>(async () =>
|
||||
await drv.InitializeAsync("{}", TestContext.Current.CancellationToken));
|
||||
|
||||
ex.Message.ShouldContain("TimeoutException");
|
||||
ex.Message.ShouldContain("PerEndpointConnectTimeout (0.4 s)");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user