Thanks Avinash. I tried your example and it does seem to help. So if I'm emitting a stream from my server, should I be checking isReady() before each onNext() call? I'm currently reading an InputStream and chunking out to the response, so really what I'm doing is "waiting" (while/sleep) for isReady to be true on each read from the InputStream. This does seem to prevent the server throwing an OOM but not sure if this is the best way?
I really wish there were a way to do a blocking stream write/read so the backpressure handling was driven by the client reads. Having to wait/sleep or react to asynchronous messages in the server (for example, client could send a "pause" message, server could "sleep") feels complicated and brittle. Am I missing something with how I'm approaching this?