nats-io / nats-server

High-Performance server for NATS.io, the cloud and edge native messaging system.
https://nats.io
Apache License 2.0
15.56k stars 1.39k forks source link

Bug of "JetStream not enabled for account (10039)" #3071

Closed xieyuschen closed 1 year ago

xieyuschen commented 2 years ago

@matthiashanel @kozlovic Currently, we have many issues about JetStream not enabled for account (10039). I tried to debug it with the nats-server and found there is a $G account. I tried to find it in our documents but no useful docs there. So could I ask what's the default behavior when we want to get the account info by nats account info? I would like it to get all jetstream enabled account, but now nats-server returns the JetStream not enabled for account (10039) error to user as the $G account is not enabled.

I debug it on macOS with Goland, the code is aligned with the master branch. The config file foo.conf is this one:

jetstream {

    max_mem: 1G
    max_file: 100G
}

accounts {
    HR: {
    jetstream: enable
    }
}}

I debug with argument --jetstream --config /Users/yuchenxie/Documents/NATS/foo.conf the foo.conf is shown up.

When I see the code which gets the account:

image

It will get the $G account. But actually, there is an account named HR with jetstream enabled and the user would like to get it.

image

Thanks for reviewing :)

derekcollison commented 2 years ago

The config does not show how one would authenticate to be attached to the defined HR account. By default you will be bound to the $G (global account).

If you want users to bind to the HR account you need to specify how they would do so. Either through authentication, like user/password or nkeys and JWTs.

If you are just starting and do not require authentication as of yet, you could have all non-authenticated users be bound to HR. Here is an example of how to accomplish that.

jetstream {
    max_mem: 1G
    max_file: 100G
}

no_auth_user: default-user

accounts {
    HR: {
    jetstream: enable
    users = [ { user: default-user} ]
    }
}}
xieyuschen commented 2 years ago

The config does not show how one would authenticate to be attached to the defined HR account. By default you will be bound to the $G (global account).

If you want users to bind to the HR account you need to specify how they would do so. Either through authentication, like user/password or nkeys and JWTs.

If you are just starting and do not require authentication as of yet, you could have all non-authenticated users be bound to HR. Here is an example of how to accomplish that.

jetstream {
    max_mem: 1G
    max_file: 100G
}

no_auth_user: default-user

accounts {
    HR: {
  jetstream: enable
  users = [ { user: default-user} ]
    }
}}

Thanks, dereck. I will try it and learn more about it.

Allan-Nava commented 6 months ago

The config does not show how one would authenticate to be attached to the defined HR account. By default you will be bound to the $G (global account).

If you want users to bind to the HR account you need to specify how they would do so. Either through authentication, like user/password or nkeys and JWTs.

If you are just starting and do not require authentication as of yet, you could have all non-authenticated users be bound to HR. Here is an example of how to accomplish that.

jetstream {
    max_mem: 1G
    max_file: 100G
}

no_auth_user: default-user

accounts {
    HR: {
  jetstream: enable
  users = [ { user: default-user} ]
    }
}}

What does it mean HR? Also how can I limit the topics for the default users?