NATS.IO NATSNoRespondersException

Viewed 2785

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

3 Answers

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/

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

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);
    }
Related