Skip to content

[BUG] ServiceBusReceiver.PeekMessageAsync does not respect cancellation token on connect failure #52620

@andradf

Description

@andradf

Library name and version

Azure.Messaging.ServiceBus 7.20.1

Describe the bug

For cases when the service bus endpoint is not reachable, the cancellation token passed to PeekMessageAsync is not respected.

Expected behavior

The call to PeekMessageAsync should timeout on a failed connection attempt in accordance to the cancellation token passed in the call.

Actual behavior

the connection times out at a fixed 65 seconds.

Reproduction Steps

Execute the following in an environment where the service bus instance cannot be reached.

var service_bus_client = new Azure.Messaging.ServiceBus.ServiceBusClient("<CSTR>");
var receiver = service_bus_client.CreateReceiver("ej-file-commands");
CancellationTokenSource cts = new CancellationTokenSource(TimeSpan.FromSeconds(5));
cts.Token.Register(() => Console.WriteLine("Cancellation requested"));
await receiver.PeekMessageAsync(cancellationToken: cts.Token);

Environment

Windows and .net runtime 9.0.8

Metadata

Metadata

Assignees

Labels

ClientThis issue is related to a non-management packageService Buscustomer-reportedIssues that are reported by GitHub users external to the Azure organization.issue-addressedWorkflow: The Azure SDK team believes it to be addressed and ready to close.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions