diff --git a/UaClient/ServiceModel/Ua/Channels/ClientSecureChannel.cs b/UaClient/ServiceModel/Ua/Channels/ClientSecureChannel.cs index a149070..9566c25 100644 --- a/UaClient/ServiceModel/Ua/Channels/ClientSecureChannel.cs +++ b/UaClient/ServiceModel/Ua/Channels/ClientSecureChannel.cs @@ -148,13 +148,7 @@ public virtual async Task RequestAsync(IServiceRequest request // TimestampHeader takes care that the RequestHeader property will not be null using (var timeoutCts = new CancellationTokenSource((int)request.RequestHeader!.TimeoutHint)) using (var linkedCts = CancellationTokenSource.CreateLinkedTokenSource(timeoutCts.Token, _channelCts.Token, token)) - using (var registration = linkedCts.Token.Register(o => - { - var statusCode = StatusCodes.BadRequestTimeout; - if (PeakFirstPendingException() is ServiceResultException result) - statusCode = result.StatusCode; - ((ServiceOperation)o!).TrySetException(new ServiceResultException(statusCode)); - }, operation, false)) + using (var registration = linkedCts.Token.Register(o => ((ServiceOperation)o!).TrySetException(GetPendingException() ?? new ServiceResultException(StatusCodes.BadRequestTimeout)), operation, false)) { if (_pendingRequests.Post(operation)) {