nats-io / natscli

The NATS Command Line Interface
Apache License 2.0
480 stars 95 forks source link

nats sub --stream does not respect the --js-domain flag #1073

Closed Zambito1 closed 3 months ago

Zambito1 commented 3 months ago

Observed behavior

When you connect to a server that is in one JS domain and you specify --js-domain or use a context with a JS domain specified you cannot subscribe to streams from the specified domain, but you can subscribe to streams from the domain of the server you are connected to.

Expected behavior

You should be able to subscribe to streams from other JS domains, and you should not be able to subscribe to streams from the JS domain of the current server when you specify a domain other than the one the server is in.

Server and client version

CLI: 0.1.4 Server: 2.10.16

Host environment

Running the official Docker containers on a 64 bit GNU/Linux machine.

Steps to reproduce

ripienaar commented 3 months ago

Thanks for the report,

Do you mind adding --trace to the command arguments?

Here you can see picking a domain does result in the API trying to access the stream in the domain:

$ nats sub --stream X --js-domain foo --trace
09:40:09 >>> $JS.foo.API.STREAM.INFO.X

this indicates its accessing the domain correctly

Zambito1 commented 3 months ago
nats --js-domain A s add foo
nats --js-domain B s add bar

nats pub foo.foo foo
nats pub bar.bar bar

nats --js-domain B sub --stream foo --trace # Note, foo is on domain A
<<< Reply Subject: $JS.ACK.foo.OKmk1lpA.1.1.1.1718197970030690510.0
[#1] Received JetStream message: stream: foo seq 1 / subject: foo.foo / time: 2024-06-12T09:12:50-04:00
foo

nats --js-domain B sub --stream bar --trace
nats: error: nats: stream not found

nats --js-domain B s ls # Shows bar with 1 message
ripienaar commented 3 months ago

The —trace flag is only useful if you show the new output like in my example.

Zambito1 commented 3 months ago

Sorry, I'm not sure what you mean. Are you referring to the output of the sub --stream bar --trace? If so, I copied the output verbatim: image

Zambito1 commented 3 months ago

Same with the sub --stream foo --trace: image

ripienaar commented 3 months ago

Ok perhaps the trace behaviour are in main only. To me this seems fixed for the next release.

ripienaar commented 3 months ago

Yes, fixed here https://github.com/nats-io/natscli/commit/b213da188a4e91b51862869868e50996c92c9ca6 and not yet released.