Can't get messages from server A in server B using LeafNodes

20 views
Skip to first unread message

Thales Maia

unread,
Feb 21, 2025, 5:29:58 PMFeb 21
to nats

Hi there,

I need some help with NATS leaf nodes and JetStream. Here’s my setup:

  1. Local Setup (Working):

    • Two local servers (nats-red and nats-blue) connected to NGS.

    • I can publish in nats-red and subscribe in nats-blue (both with and without JetStream).

  2. VPS Setup (Not Working):

    • Deployed a new server (natsmycity) on a VPS with JetStream enabled.

    • Created a stream:

      nats stream add my-stream --subjects "my-subject" --storage file --retention limits --max-msgs=-1 --max-bytes=-1 --max-age=1y --discard old -s nats://user:password@localhost:4222 --domain=br_mg_mycity
    • Publishing messages to my-subject:

      while true; do nats pub -s nats://user:password@localhost:4222 my-subject "Hello from natsmycity with JetStream" --domain=br_mg_mycity; sleep 1; done;
    • Issue: When I try to subscribe to my-subject on nats-red, I don’t see any messages:

      nats sub -s localhost:4223 my-subject
  3. Configurations:

    • natsmycity (VPS):

      port: 4222  
      http: 8222  
      server_name: natsmycity  
      jetstream {  
          max_mem: 2G  
          store_dir: "/data"  
          max_file: 5Gi  
          unique_tag: "br_mg_mycity"  
          domain: "br_mg_mycity"  
      }  
      leafnodes {  
          remotes = [  
              {  
                  url: "tls://connect.ngs.global:7422"  
                  credentials: "/etc/nats/NGS-Default-blue.creds"  
              }  
          ]  

    • nats-red (Local):

      port: 4223  
      http: 8222  
      jetstream {  
          max_mem: 2G  
          store_dir: "/data"  
          max_file: 5Gi  
          domain: "debian"  
      }  
      leafnodes {  
          remotes = [  
              {  
                  url: "tls://connect.ngs.global:7422"  
                  credentials: "/etc/nats/NGS-Default-red.creds"  
              }  
          ]  
      }
  4. What I’ve Tried:

    • Verified that both servers are connected to NGS.

    • Confirmed that the stream is created and messages are being published.

    • Checked NATS logs for errors (none found).

  5. Question:

    • Why aren’t messages published on natsmycity appearing in nats-red?

    • Am I missing something obvious in the configuration?

Any help would be greatly appreciated!

Reply all
Reply to author
Forward
0 new messages