Skip to content

[BUG] Event Hubs: no CBS responder is started, so Azure SDKs cannot authorize over AMQP #227

Description

@deyanp

Event Hubs namespaces start an Artemis broker with nothing answering $cbs. The
put-token every Azure SDK sends before its first link gets a reply with no
status-code, and the client fails. Service Bus namespaces get a responder and do not
have this problem.

Both brokers start; only one gets a responder:

INFO [io.flo.az.ser.eve.EventHubNamespaceManager]  Starting Artemis broker for Event Hubs namespace 'emulatorNs1' (plain:5,672, TLS:5,671)
INFO [io.flo.az.ser.ser.ServiceBusNamespaceManager] Starting Artemis broker for Service Bus namespace 'default' (plain:5,673, TLS:5,674)
INFO [io.flo.az.ser.ser.ServiceBusCbsResponder]     CBS responder started for 172.17.0.13:5,672

Repro

docker run -d --name floci-az \
  -e FLOCI_AZ_SERVICES_EVENT_HUB_MOCKED=false \
  -e FLOCI_AZ_SERVICES_SERVICE_BUS_MOCKED=false \
  -p 4577:4577 -v /var/run/docker.sock:/var/run/docker.sock \
  floci/floci-az:latest

curl -s -X PUT http://localhost:4577/devstoreaccount1-eventhub/namespaces/emulatorNs1 \
  -H 'Content-Type: application/json' -d '{}'

curl -s -X PUT http://localhost:4577/devstoreaccount1-servicebus/test-hub \
  -H 'Content-Type: application/atom+xml' \
  -d '<entry xmlns="http://www.w3.org/2005/Atom"><content type="application/xml"><QueueDescription xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"/></content></entry>'

(Do not publish 5672/5673 on the floci-az container — the sidecars bind those host
ports themselves.)

Client — Rust, azure_messaging_eventhubs 0.15:

use std::sync::Arc;
use azure_core::credentials::{AccessToken, TokenCredential, TokenRequestOptions};
use azure_messaging_eventhubs::ProducerClient;

#[derive(Debug)]
struct AnyToken; // floci accepts any token

#[async_trait::async_trait]
impl TokenCredential for AnyToken {
    async fn get_token(&self, _: &[&str], _: Option<TokenRequestOptions<'_>>)
        -> azure_core::Result<AccessToken> {
        Ok(AccessToken::new("any-token",
            azure_core::time::OffsetDateTime::now_utc() + azure_core::time::Duration::hours(1)))
    }
}

#[tokio::main]
async fn main() {
    let endpoint = std::env::var("ENDPOINT").unwrap_or("amqp://localhost:5672".into());
    let producer = ProducerClient::builder()
        .with_custom_endpoint(endpoint)
        .open("emulatorns1.servicebus.windows.net", "test-hub", Arc::new(AnyToken))
        .await.unwrap();
    // first call that authorizes a path
    println!("{:?}", producer.create_batch(None).await.err());
}

Observed

ENDPOINT=amqp://localhost:5672   # Event Hubs
create_batch FAILED: Transport Implementation Error: StatusCode is nor found

ENDPOINT=amqp://localhost:5673   # Service Bus, same client
create_batch FAILED: Management API returned status code: 200 (OK)

Expected: create_batch succeeds, as against a real namespace.

Analysis

The two errors give the diagnosis:

  • 5672 — no status-code in the reply at all: nothing implements $cbs. Artemis
    auto-creates the address and reply-to node, but there are no CBS semantics behind it.
  • 5673 — a status-code is present, so the responder answered. It replies 200;
    CBS put-token must return 202. fe2o3-amqp-cbs hard-codes
    const STATUS_CODE: u16 = 202 (put_token.rs:93) and rejects the 200.

Suggested fix

  1. Start a CBS responder for Event Hubs namespaces. ServiceBusCbsResponder already
    exists and is started by ServiceBusNamespaceManager; EventHubNamespaceManager
    starts its Artemis without one.
  2. Reply 202 rather than 200 to put-token — this also affects Service Bus clients on
    strict CBS implementations.

Follow-on gaps

CBS alone will not complete a round-trip. The next two calls are:

Happy to test any of these.

Environment

floci-az 0.11.0 (sha256:6566c73b8f4b6e3ef90322c8c84a47258bb1ca13c82ea1d40027f7af11247e30, arm64)
Artemis apache/activemq-artemis:2.44.0
Docker 28.4.0, Darwin arm64
Client azure_messaging_eventhubs 0.15.0, azure_core_amqp 1.0.0, fe2o3-amqp-cbs 0.14.0

Event Hubs AMQP landed in #17 and appears not to have had the SDK-compat work Service
Bus has since received (#128, #159, #170). This looks like its counterpart.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingeventhubAzure Event Hubs

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions