Skip to content

Make Request Cancellation in the Server compatible with Async Code #3348

@romanett

Description

@romanett

Currently if the Client cancels a request using the Cancel Servicecall each Service needs to check the OperationContexts OperationStatus to see if the request is cancelled.

If a request times out with the TimeOutHint of the Client however the CancellationToken of the request is set.

The CancellationTokenSource of the request is however not accessible in the OperationContext for the RequestManager to cancel async operations using the CancellationToken.

Also the StatusCode needs to be considered eg. StatusCodes.BadRequestCancelledByRequest.

The Requests handling of the Server needs to be reconsidered to fix this.

Currently the EndpointBase creates an EndpointIncomingRequest This request is enqued into the RequestQueue

Each worker of the RequestQueue now calls back into the registered Service using ServiceDefinition.InvokeAsync

This only propagates the CancellationToken + RequestHeader + SecureChannelContext from the TransportChannel (not currently in use) and the CancellationToken being cancelled after the TimeOutHint of the Client expires.

From this RequestHeader +SecureChannelContext the StandardServer now creates an OperationContext and "registers" this Operation in the RequestManager. The request Manager is now used by the Cancel Service to set a StatusCode if a request shall be cancelled by the Cancel Service Call.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementAPI or feature enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions