Azure / azure-service-bus-emulator-installer

This repository acts as a central hub for handling issues, collecting feedback, and facilitating discussions related to the Azure Service Bus Emulator.
https://learn.microsoft.com/en-us/azure/service-bus-messaging/overview-emulator
MIT License
100 stars 2 forks source link

Can't connect to Emulator #25

Open ahrytsiuk opened 1 day ago

ahrytsiuk commented 1 day ago

I run emulator using docker-compose.yml provide in the example. And I'm trying to connect to it from Spring application which uses Spring Cloud Streams binder for Azure Service Bus:

<dependency>
    <groupId>com.azure.spring</groupId>
    <artifactId>spring-cloud-azure-stream-binder-servicebus</artifactId>
</dependency>
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.azure.spring</groupId>
            <artifactId>spring-cloud-azure-dependencies</artifactId>
            <version>5.18.0</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

with the following configuration:

spring:
  cloud:
    stream:
      default-binder: servicebus
    azure:
      servicebus:
        connection-string: Endpoint=sb://localhost;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SAS_KEY_VALUE;UseDevelopmentEmulator=true;

However I get the following error:

2024-11-20T17:08:59.839+01:00  WARN [app,,] 39260 --- [app] [ctor-executor-1] [ ] c.a.c.a.i.handler.ConnectionHandler      : {"az.sdk.message":"onTransportError","connectionId":"MF_c5f479_1732118939411","errorCondition":"proton:io","errorDescription":"Connection refused","hostName":"localhost"}
2024-11-20T17:08:59.839+01:00  WARN [app,,] 39260 --- [app] [ctor-executor-2] [ ] c.a.c.a.i.handler.ConnectionHandler      : {"az.sdk.message":"onTransportError","connectionId":"MF_5c3359_1732118939474","errorCondition":"proton:io","errorDescription":"Connection refused","hostName":"localhost"}
2024-11-20T17:09:03.870+01:00  WARN [app,,] 39260 --- [app] [ctor-executor-1] [ ] c.a.c.a.i.ReactorConnection              : {"az.sdk.message":"Error occurred while processing connection state.","exception":"Connection refused, errorContext[NAMESPACE: localhost. ERROR CONTEXT: N/A]","connectionId":"MF_c5f479_1732118939411"}
2024-11-20T17:09:03.870+01:00  WARN [app,,] 39260 --- [app] [ctor-executor-2] [ ] c.a.c.a.i.ReactorConnection              : {"az.sdk.message":"Error occurred while processing connection state.","exception":"Connection refused, errorContext[NAMESPACE: localhost. ERROR CONTEXT: N/A]","connectionId":"MF_5c3359_1732118939474"}

Could you please provide an example how to connect to emulator?

danielproctor31 commented 1 day ago

EDIT: I was using a slightly older version of Azure.Messaging.ServiceBus in my repo. Using the one specified in the example resolves it. 7.18.2

Also having the same issue with the provided docker compose and .NET sample.

Container up and running:

2024-11-20 17:12:42 info: a.F.aFu[0]
2024-11-20 17:12:42       Creating user defined entities for SB Emulator
2024-11-20 17:12:42 info: a.F.aFu[0]
2024-11-20 17:12:42       Creating queue: queue.1 
2024-11-20 17:12:42 info: a.F.aFu[0]
2024-11-20 17:12:42       Creating topic: topic.1 
2024-11-20 17:12:42 info: a.F.aFu[0]
2024-11-20 17:12:42       Creating subscription subscription.1 for topic: topic.1 
2024-11-20 17:12:42 info: a.F.aFu[0]
2024-11-20 17:12:42       Processing filters for subscription subscription.1 for topic: topic.1 
2024-11-20 17:12:42 info: a.F.aFu[0]
2024-11-20 17:12:42       Processing filter app-prop-filter-1
2024-11-20 17:12:43 info: a.F.aFu[0]
2024-11-20 17:12:43       Creating subscription subscription.2 for topic: topic.1 
2024-11-20 17:12:43 info: a.F.aFu[0]
2024-11-20 17:12:43       Processing filters for subscription subscription.2 for topic: topic.1 
2024-11-20 17:12:43 info: a.F.aFu[0]
2024-11-20 17:12:43       Processing filter user-prop-filter-1
2024-11-20 17:12:43 info: a.F.aFu[0]
2024-11-20 17:12:43       Creating subscription subscription.3 for topic: topic.1 
2024-11-20 17:12:43 info: a.F.aFu[0]
2024-11-20 17:12:43       Processing filters for subscription subscription.3 for topic: topic.1 
2024-11-20 17:12:43 info: a.F.aFu[0]
2024-11-20 17:12:43       Triggering Entity Sync
2024-11-20 17:12:44 info: a.F.aFu[0]
2024-11-20 17:12:44       Entity Sync complete; Operation Result:True
2024-11-20 17:12:44 info: a.F.aFu[0]
2024-11-20 17:12:44       User defined entities created for SB Emulator
2024-11-20 17:12:44 info: a.F.aFO[0]
2024-11-20 17:12:44       Emulator Service is Successfully Up!

.NET error:

Service Bus Emulator .NET Sample
Running Case 1: Send Receive from a Queue
Unhandled exception. Azure.Messaging.ServiceBus.ServiceBusException: No connection could be made because the target machine actively refused it. ErrorCode: ConnectionRefused (ServiceCommunicationProblem). For troubleshooting information, see https://aka.ms/azsdk/net/servicebus/exceptions/troubleshoot.
 ---> System.Net.Sockets.SocketException (10061): No connection could be made because the target machine actively refused it.
   at Microsoft.Azure.Amqp.ExceptionDispatcher.Throw(Exception exception)
   at Microsoft.Azure.Amqp.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at Microsoft.Azure.Amqp.Transport.AmqpTransportInitiator.ConnectAsyncResult.End(IAsyncResult result)
   at Microsoft.Azure.Amqp.Transport.AmqpTransportInitiator.<>c.<ConnectAsync>b__17_1(IAsyncResult r)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location ---
talbx commented 19 hours ago

@ahrytsiuk do you have any updates from your side? I am struggling with the exact same issue. Usingspring-cloud-azure-stream-binder-servicebus:5.17.1.

Must be some sort of limitation of the sdk. I found this issue and from what I understand, it looks like spring-cloud-azure-stream-binder-servicebus requires TLS for setting up a connection by default and the emulator does not support it to reduce unnecessary overhead.

For me it looks like we have to wait until Azure provides a fix in the sdk for it. @krishankumar95 does that also sound right to you?

@danielproctor31 is this really related? we are talking about connection issues when using the the mentioned spring dependency (Java/Kotlin context). Your log and obviously the .NET error seem to stem from a non-java application.

danielproctor31 commented 17 hours ago

@talbx The issue is regarding connection to the emulator, which I was also having. As you can see from my edit I resolved that so feel free to ignore my comment. It may help if anyone else runs into the same problem.

ahrytsiuk commented 16 hours ago

@talbx I didn't try to find solution since I created an issue. But it seems you are right that binder library needs to acomodate changes to support emulator.