A problem with nats client
See original GitHub issueI’m new on nats, Today, I’ve installed nats client on node.js but cannot publish a message, so, I’m getting weird error. How can I fix this error?
My code:
const nc = require('nats').connect({'servers': ['nats://127.0.0.1:4222']});
nc.publish('foo', 'Hello World!');
Error:
TypeError: nc.publish is not a function
Issue Analytics
- State:
- Created a year ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Problem with indefinite reconnect · Issue #325 · nats-io/nats.c
Hello. I've asked you a question some time ago about slow consumers and the reason nats client can be disconnected from server.
Read more >io.nats.client (jnats 1.0 API) - javadoc.io
If NATS detects a serious problem with a Connection object, it informs the Connection object's ExceptionHandler , if one has been registered.
Read more >NATS streaming reconnecting to a subscription - Google Groups
The problem I'm trying to solve is for a client to reconnect after some communication failure without missing any messages. A MsgProto contains...
Read more >Slow Consumers - NATS Docs
Most client libraries will notify the application that there is a SlowConsumer error and discard messages. Receiving and dropping messages from the server...
Read more >Java Nats Client: Incomprehensible error message "Subject ...
It comes from io.nats.jnats version 2.8 (nats.client.impl.NatsConnection # deliverReply). But we don't notice any problem in our system.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Maybe look here.
https://github.com/nats-io/nats.js/blob/main/README.md
Also my guess is you need to await the connection.
Also - there are a couple of issues with the code above. Your code is publishing a message before the subscription is registered, so your two publishes will be received by the server before the subscription is registered, so your subscription will not get the messages.