nats.js: Can't connect to server with token authentication.

Hello, First off thank you for writing this code. We rely on NATS and js so this is very useful for us.

I have tried connecting to a remote NATS server with token authentication and can’t. My subscriptions don’t receive data I send. I’m using nats@beta. My code works fine when testing with a local server that has token authentication. Our remote server is 3 NATS instances as a supercluster behind a Kubernetes load balancer.

Can you help me debug this? I tried Python and nats-pub/nats-sub; they work successfully.

Here is my sample code: https://gist.github.com/roguh/9c220782640279d040ee563c23300432

Here’s the output:

$ 
NATS_AUTH_TOKEN=... NATS_URL=nats://localhost:4222 node src/nats_test.js
subscribing to test
publishing to test
Error: test publish and subscribe failed. messages received: 

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 21 (8 by maintainers)

Most upvoted comments

Your sample runs fine.

I caught the problem! I didn’t use {callback: ...}

It would be helpful for you to show your server configuration.