Reputation: 91
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
Upvotes: 4
Views: 12995
Reputation: 321
You get a 'no responder' when the server knows that there are no processes currently listening for your request. Rather than publishing the request and getting a timeout if 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.
See this link for more information.
Upvotes: 5
Reputation: 4393
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.
Upvotes: 1
Reputation: 61
This could be too late now, but this Error also pops up when you push to a NON-EXISTING Subject!
Upvotes: 1
Reputation: 119
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/
Upvotes: 9
Reputation: 91
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);
}
Upvotes: 0