2

I'm new to NATS and I have taken over an almost finshed application in NetCore 5.0. When I'm startning the application a Connection is set to an docker NATS server and this properties are set in appsettings.

"NatsSettings": {
  "Url": "nats://localhost:4222",
  "StreamName": "nats-server",
  "Timeout": 10000,
  "Verbose": true,
  "StreamReceivedSubject": "TestData.received.Subject",
  "ReceivedConsumerName": "TestData.Received.Consumer.Name",
  "ConsumerReceivedSubject": "TestData.Consumer.Received.Subject",
  "ConsumerReceivedFilter": "TestData.Received.Filter",
  "Subjects": [
    "TestData.*"
  ]
}

What am I missing in the settings for the connection? The error message I keep on getting is NATS.Client.NATSNoRespondersException: 'No responders are available for the request.'

Can anyone help me?

KR Jörgen

Jono
  • 71
  • 2
  • 8
  • I'm struggling with something similar. I was told I had to make sure that both the server and the account I'm using are JetStream enabled. I'm not posting this as an answer because I don't know if that's the same problem you are facing, and also I'm myself not able to solve it because I don't know how to enable JetStream for the account I'm using. As far as I understand I'm not even using any account... – Julien Debache Apr 01 '22 at 19:53
  • I was able to reproduce this error (`ErrNoResponders` in Go client) with getting from KV via making a call to `KeyValue.Get()` providing a string with double dots (like `foo..bar`) instead of a single dot (like `foo.bar`). In my case it was just a typo. May be helpful. – Glebsa Jul 02 '23 at 14:11

5 Answers5

7

I got this error because I haven't enabled jetstreams

Run docker image with -js tag. It will work

 docker run -p 5555:4444 nats -p 4444 -js

For More reference https://hub.docker.com/_/nats/

Rupak
  • 99
  • 2
  • 6
  • Either this or you have not created any jet streams in the broker, for example using the nats CLI `nats stream add` – jonaslagoni Oct 22 '22 at 13:40
4

You get a 'no responder' when the server knows that there are no processes listening currently listening for your request, so rather than publishing the request and getting a timeout after some time because there are is no-one listening for those requests this exception is there to let you know right away that there is currently no-one to service your request.

https://docs.nats.io/whats_new_22#react-quicker-with-no-responder-notifications

JNM
  • 221
  • 2
  • 5
1

This could be too late now, but this Error also pops up when you push to a NON-EXISTING Subject!

0

more specific, this is where it happens

    private bool StreamExists(IConnection connection, string streamName)
    {
        string json = "{\"offset\":0}";
        Msg message = connection.Request(NatsConstants.STREAMNAMESCMD, Encoding.UTF8.GetBytes(json), 3000); // HERE
        string responseString = Encoding.UTF8.GetString(message.Data);

        return responseString.Contains(streamName);
    }
Jono
  • 71
  • 2
  • 8
0

I ran into this issue in a c# code base and the way I solved it was by ensuring the sub' method was active first before the requester method was called.

I started by narrowing my runtime code down to the 2️⃣ tasks that were causing the issue to replicate it first. Then re-did the order they were executed in. Then I observed that order matters when it comes to NATs.

Quite different to how Azure Service Bus, things can start in any order but NATs based on localhost debugging,

I have had to re-order by background worker class to ensure any tasks that had a _natsClient.SubscribeAsync() call within were ran first then any tasks that a _natsClient.RequestAsync() call within were ran second.

Hope this helps someone.

IbrarMumtaz
  • 4,235
  • 7
  • 44
  • 63