Skip to content

TopicClient always receive 401 #1637

@Gaelik-git

Description

@Gaelik-git

I created a Service Bus Namespace with:

  • One Queue : dev
  • One Topic : test-topic
    • One Subscription : test-subscription

I also have a Sharred access Policies on the Namespace level named common
But the topic client always receives a 401, when my QueueClient receives 204

Can you help me with this ? Is my code incorrect ?
Can it be linked to the ordering when creating things ?
I am using the latest 0.19 version of the sdk with rust 1.77.1

This is the result of this test program

INFO peeked message queue val=204
INFO send message to topic ko=Error { context: Simple(HttpResponse { status: Unauthorized, error_code: None }) }
INFO peeked message from subscription val=401
use azure_messaging_servicebus::service_bus::{QueueClient, TopicClient};
use reqwest::Client;
use std::sync::Arc;
use std::time::Duration;
use tracing::{info, subscriber::set_global_default};

#[tokio::main]
async fn main() {
    // common conf
    let namespace = "REDACTED";
    let policy_name = "common";
    let policy_key = "REDACTED";

    // topic conf
    let topic_name = "test-topic";
    let subscription_name = "test-subscription";

    // queue conf
    let queue_name = "dev";

    set_global_default(tracing_subscriber::fmt::Subscriber::new())
        .expect("set tracing default subscriber");

    let client = QueueClient::new(
        Arc::new(Client::new()),
        namespace,
        queue_name,
        policy_name,
        policy_key,
    )
    .unwrap();
    let val = client
        .peek_lock_message2(Some(Duration::from_micros(1)))
        .await
        .unwrap();

    info!(val = %val.status(), "peeked message queue");
    let client = TopicClient::new(
        Arc::new(Client::new()),
        namespace,
        topic_name,
        policy_name,
        policy_key,
    )
    .unwrap();

    let val = client.topic_sender().send_message("msg").await;

    match val {
        Ok(_) => info!(ok = ?val.is_ok(), "send message to topic"),
        Err(_) => info!(ko = ?val.unwrap_err(), "send message to topic"),
    }

    let val = client
        .subscription_receiver(subscription_name)
        .peek_lock_message2(Some(Duration::from_micros(1)))
        .await
        .unwrap();

    info!(val = %val.status(), "peeked message from subscription");
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    ClientThis issue points to a problem in the data-plane of the library.Service BusService BusbugThis issue requires a change to an existing behavior in the product in order to be resolved.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions