Closed robertmircea closed 1 year ago
I think I fixed this in the unreleased version. Will be coming this week. I could build a pre-release today if you like for you to try.
Yes, I would like to try. Thanks.
Yes, this was addressed here, I had found the same problem in testing.
So the NRE was because this method used to return null, but now it will throw an exception instead.
I suppose the only thing for discussion would be is the NATSTimeoutException
a good exception, or should it bee something else. My thinking was the connection is gone, no message is coming, timeout seems fair.
I'm actually trying to get a release out, so please be patient, it should be today or tomorrow.
1.0.5 has been released
I've upgraded the solution to use the new nuget packatge and I repeated the scenario: I started consuming and, at some point during consumption, I stopped the server. This time, I didn't receive the NRE exception and when I restarted the server, the client resumed message processing. After some time, the client started printing the following "warning" (because it does not crash the process)
PullStatusWarning, Connection: 243, Subscription: 2, ConsumerName:f79986685fe44655b98bffb08a872eba, Status: Status 408 Request Timeout
PullStatusWarning, Connection: 243, Subscription: 2, ConsumerName:f79986685fe44655b98bffb08a872eba, Status: Status 408 Request Timeout
PullStatusWarning, Connection: 243, Subscription: 2, ConsumerName:f79986685fe44655b98bffb08a872eba, Status: Status 408 Request Timeout
I put the nats server in debug/verbose mode and I see that the above message is generated when the client performs jetStreamPullSubscription.NextMessage
:
[8700] 2023/06/21 11:37:03.350429 [TRC] [::1]:50748 - cid:243 - <<- [PUB $JS.API.CONSUMER.MSG.NEXT.dev-auditevents.f79986685fe44655b98bffb08a872eba _INBOX.hngpn6EaoOdomEUi-vYfk9.10111 33]
[8700] 2023/06/21 11:37:03.350431 [TRC] [::1]:50748 - cid:243 - <<- MSG_PAYLOAD: ["{\"batch\":100,\"expires\":500000000}"]
Not sure how to interpret this.
Those are just normal warnings for pull. Consider your pull
jetStreamPullSubscription.PullExpiresIn(100, 500);
The 408 means that server did not get 100 messages during the 500 ms expiration period and the pull is complete. I'm considering offering a pull request option to turn off warnings as you already get a timeout. You can also modify the PullStatusWarningEventHandler to not show that particular warning.
Description
I encountered a
NullReferenceException
inNATS.Client.JetStream.PullMessageManager.Manage(Msg msg)
when running the NATS subscriber application using the NATS client library (version 1.0.4) in a scenario where the NATS server is cleanly shutdown, and the consumer tries to fetch the next message from the server.Environment
NATS Server Version: 2.9.18 NATS Client Library Version: 1.0.4 MacOS Ventura 13.4
Steps to Reproduce
Start the NATS server.
Expected Behavior
The subscriber application should handle the server shutdown gracefully, without throwing an exception, and continue execution when the server is back online.
Actual Behavior
After the NATS server is shut down, the subscriber application throws a "Connection closed" exception after a period of time.
Output
Additional Information