Skip to content

[BUG] SDK does not throw an error when connecting to Azure Service Bus if ports 5671 and 5672 are blocked #49802

Description

@muskaan62

Describe the bug
When outbound ports 5671 and 5672 are blocked, the SDK does not report any connection failure while attempting to connect to Azure Service Bus. Instead of failing with an exception, the connection attempt appears to succeed or remains unaffected, even though network access through the blocked ports should prevent connectivity.

Exception or Stack Trace
No exception or stack trace is generated.

To Reproduce

  • Configure the application to connect to an Azure Service Bus namespace using the SDK.
  • Block outbound traffic on ports 5671 and 5672 using firewall rules or network policies.
  • Run the application and create a Service Bus client.
  • Attempt to establish a connection or perform a send/receive operation.
public static void main(String[] args) {
        IterableStream<ServiceBusReceivedMessage> receivedMessages;
        CONNECTION_STRING = "Endpoint=sb://*****.servicebus.windows.net/;SharedAccessKeyName=****;SharedAccessKey=****";
        try {
            // Scenario 1: Auto-acknowledge with message limit
            ServiceBusClientBuilder clientBuilder = new ServiceBusClientBuilder()
                    .connectionString(CONNECTION_STRING);

            receiver = clientBuilder
                    .receiver()
                    .maxAutoLockRenewDuration(Duration.ofSeconds(5))
                    .queueName(QUEUE_NAME)
                    .disableAutoComplete()
                    .receiveMode(ServiceBusReceiveMode.PEEK_LOCK)
                    .prefetchCount(0)
                    .buildClient();
            receivedMessages = BigInteger.valueOf(5) == null
                    ? receiver.receiveMessages(1)
                    : receiver.receiveMessages(1, Duration.ofSeconds(5));
            receivedMessages.stream().forEach(m -> {
                System.out.println("\n[PROCESS] Message:");
                System.out.println("  ID: " + m.getMessageId());
                System.out.println("  Sequence: " + m.getSequenceNumber());
                System.out.println("  Subject: " + m.getSubject());
                System.out.println("  Content: " +  m.getBody().toString());
                System.out.println("  Delivery Count: " + m.getDeliveryCount());
                receiver.complete(m);
                System.out.println("acknowledged message: " + m.getMessageId());

            });
            receiver.close();

        } catch (Exception e) {
            System.err.println("[ERROR] " + e.getMessage());
            e.printStackTrace();
            receiver.close();
        }
        System.out.println("\n" + "=".repeat(80));
        System.out.println("Simulation completed!");
    }

Expected behavior

The SDK should detect that the required network ports are unavailable and fail the connection or operation with an appropriate network-related exception.

Actual behavior

No exception is thrown. The SDK does not report a connection failure even though ports 5071 and 5072 are blocked.
Screenshots

Setup (please complete the following information):

  • OS: linux ubuntu
  • IDE: IntelliJ
  • Library/Libraries: com.azure:azure-messaging-servicebus:7.17.13
  • Java version: 11
  • App Server/Environment: standalone

If you suspect a dependency version mismatch (e.g. you see NoClassDefFoundError, NoSuchMethodError or similar), please check out Troubleshoot dependency version conflict article first. If it doesn't provide solution for the problem, please provide:

  • verbose dependency tree (mvn dependency:tree -Dverbose)
  • exception message, full stack trace, and any available logs

Additional context
Add any other context about the problem here.

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added

Metadata

Metadata

Assignees

No one assigned

    Labels

    ClientThis issue points to a problem in the data-plane of the library.Service AttentionWorkflow: This issue is responsible by Azure service team.Service Buscustomer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions