Closed henrychris closed 3 months ago
In the NATS Server, the BackOff option overrides the AckWait option, ignoring the AckWait settings. This can cause an inconsistency between the NATS client configuration and the server configuration, leading to exceptions when the application restarts. Since CAP internally provides a default value for AckWait, you need to reset the AckWait option to avoid configuration comparison issues.
consOpts.WithBackoff(
NATS.Client.Internals.Duration.OfSeconds(5),
NATS.Client.Internals.Duration.OfSeconds(30),
NATS.Client.Internals.Duration.OfMinutes(1),
NATS.Client.Internals.Duration.OfMinutes(2),
NATS.Client.Internals.Duration.OfMinutes(5),
NATS.Client.Internals.Duration.OfMinutes(10)
);
consOpts.WithAckWait(null); // add this line !!!!
I just tried this out, and it works! Thank you so much! Do I close this myself, or will you do the honours?
Configuration
In my Program.cs, I have CAP configured like so:
I have an interface and class:
IUserService:
UserService:
These are both registered as scoped services.
How To Reproduce
Using Docker, start a new nats server:
docker run -it -p 4222:4222 -p 8222:8222 -p 8080:8080 --name nats -d nats:2.10.14 -js -m 8222
.Set
natsUrl
inProgram.cs
to"nats://localhost:4222"
.Start the application.
Close the application.
Start the application again. This exception should appear in the terminal:
Error Log:
Expected Behaviour
An exception should not be thrown here because the consumer configuration is not changing. If I don't provide a custom consumer configuration, no exception is thrown on application restart.