nats-io / nats.rs

Rust client for NATS, the cloud native messaging system.
Apache License 2.0
1.06k stars 166 forks source link

event_callback keeps triggering client error: nats: authorization violation #1334

Open hanselke opened 11 hours ago

hanselke commented 11 hours ago

Observed behavior

    let nc_main = ConnectOptions::with_jwt(jwt, move |nonce| {
        let keypair_clone = keypair_clone.clone();
        async move { keypair_clone.sign(&nonce).map_err(async_nats::AuthError::new) }
    })
    .custom_inbox_prefix(inbox_prefix)
    .event_callback(|event| async move {
          println!("NATS event occurred: {}", event);
    })
    .connect(main_nats_url)
    .await
    .context("Cannot connect to main NATS service")?;

jwt token is issued with all perms, and 1 year expiry.

When i do nothing else, ie..no subscriptions, after a min or so i'll start seeing

NATS event occurred: client error: nats: authorization violation
NATS event occurred: client error: nats: authorization violation

one event every min or so. however when i run it with all my app features, all the features still work even tho we keep seeing this auth violation.

Expected behavior

there shouldnt be any auth violation events

Server and client version

server: 2.10.22 & 2.10.21 async nats client: 0.37.0

Host environment

mac m1. nats is running inside docker, with a local only swarm mode enabled.

Steps to reproduce

seems to just happen in my app, have not tried a bare setup to see if it happens to deduce further

corrosive4354 commented 7 hours ago

Make sure the JWT token does contain all the necessary permissions. You can check the contents of the JWT by decoding it and make sure the permissions section is correct.

Check the configuration of ConnectOptions to make sure you haven't missed any necessary settings. In particular, the configuration of custom_inbox_prefix and event_callback.

If it still doesn't work, it may be a compatibility issue between Docker and Mac. You can switch to Servbay to check the development environment