OnCompleted and OnStop are called 3 times once the stream limit or stream timeout is reached
OnCompleted and OnStop are called 3 times once the stream limit or stream timeout is reached. This happens with the latest version of the library. Currently, we are using version 0.8.5, and this one doesn't have this problem.
I'm doing two tests, one with a big stream_limit and a small stream_timeout, and the other with a big stream_timeout and a small stream_limit. Both tests deliver the same result. Please find attached the list of threads for the first OnStop call, and for the second call; they might be useful.
1st Onstop Call:

2nd OnStopCall:

Thanks for your help
I assume you configured a stream timeout, didn't you?
The cause of the problem seems to be the assumption made in successfulResponseAndCustomStreamTimeout() does not always hold true. For example, in case we successfully opened the stream (i.e. currentStreamResponseCode == 200) but there is a server error when committing the batch, the method successfulResponseAndCustomStreamTimeout() returns true but the stream itself most likely did not timeout at all. So just closing the stream and never opening it again is not the desired behaviour.
We faced the same problem and our solution was to not set a stream timeout.
Hope that helps both solving your issue and fixing this library.
@KaiStapel Thanks for the answer. Unfortunately, we need the stream timeout, as our use case requires to consume for a certain amount of time.