When is NATSNoRespondersException thrown other than when the Stream/Subject is not existing ? #753
Replies: 6 comments 6 replies
-
What I don't understand, is that I see in this pull request when this exception was introduced in NATS.NET, it says that it's thrown when "there are no subscribes" : nats-io/nats.net#413 However, I am testing locally with a single stream and 600 subjects to it, and thousands of parallel publishes on these subjects and the stream has zero consumers on the server (durable or ephemeral, no type of consumer at all). Did not call subscribe on this stream or any subject. And there is no exception. The messages are stored on the nats server (the stream is configured with File retention... until delivery) |
Beta Was this translation helpful? Give feedback.
-
So there are 2 cases where you get no responders.
You said the subject exists, but this can't be the case. |
Beta Was this translation helpful? Give feedback.
-
Hi @scottf , thank you for answering. Can you detail a bit more on point 1 ? : "When you make a core request and there are no repliers listening to the subject." :
About point 2: is clear. the Stream and Subject are there |
Beta Was this translation helpful? Give feedback.
-
In your post you said
Can you please be specific about what you mean by upsert? Are you continually modifying the stream for subjects? I'm guessing, but I'd expect that there might be a small window where subjects are not available during a stream configuration change. Have you considered using a wildcard subject instead. Something like "foo.*" and you could publish and consumer to "foo." You would never have to update the stream config for subject changes. |
Beta Was this translation helpful? Give feedback.
-
Could you post your code that creates your stream and does your publish? As far as wildcards, I think it's just better to not keep changing the stream config, and instead create it outside of your application code as an administrative function. The wildcards work well, they've been around forever. You can deal with them administratively as well. |
Beta Was this translation helpful? Give feedback.
-
You stream configuration is mostly fine. Like I said before, make the stream once, use the subject wildcards as I described before, that's what they are designed for, and leave the stream alone. Constantly modifying a stream configuration is definitely a bad idea. You are creating a new connection for each publish. (CreateConnection is not a pool, it's a full, new connection). This is a very expensive operation and will cause terrible performance if you are publishing a lot of messages. Maybe if you publish once every 10 minutes, fine. If you are publishing quite a bit, this is probably the cause of the problem, the server has so much work to do, it can't respond to other work and No Responders may simply be the symptom of this. Also see note below about publishing as a possible cause. I would make the context once per connection. and pass it to the publisher. The context itself isn't expensive, it's just unnecessary to continually make a new one and is thread-safe. I would get rid of the recursion. This construct to me seems like it is asking for trouble. Handle the failure of the publish in the place that calls the publish. Also about publishing. You can't just slam the server with an unlimited amount of async publishes, the server can't handle it. You need to collect these tasks in batches, maybe 50 or 100, and don't publish more until those publishes have all acked. (You can also have 2 threads, one publishing, queue the task and let another thread check the ack, but you need to build care into that to handle errors and also to not have too many outstanding, maybe a limited size queue) In looking for an example I realize this needs improvement (https://github.com/nats-io/nats.net/blob/master/src/Samples/JetStreamPublishAsync/JetStreamPublishAsync.cs) |
Beta Was this translation helpful? Give feedback.
-
Hello,
TL;DR: we get NATSNoRespondersException on the productive environment, but the Stream,Subject and Consumers (subscriptions) are properly setup so question is: when/why would this exception be raised for other reasons ? Not reproducible locally unless Stream does not exist.
We are facing an issue only on the prodcutive environment and I am not able to reproduce it. We get thousands of NATSNoRespondersException on Publishing a message to jetstream.
Exception is thrown when calling IJetStream. Task PublishAsync(string subject, byte[] data); method.
So far we are handling this exception on purpose, in order to upsert the Stream and Subject on the server, to achieve kind of a "self configuring at runtime" of our publishers and subscribers on the NATS JetStream.
However this spamming of NATSNoRespondersException is happenign after the Stream exists, the Subject exists, so something else is causing this exception adn I have no idea what:
So what other scenarios may be causing teh NATSNoRespondersException ?
No logs or error logs of any kind on the JetStream docker pod:
Thoughts ?
Beta Was this translation helpful? Give feedback.
All reactions