Change Stream: What is the Best Practice for connection handling?

Does the connection stay open forever by default when I run the watch()?
how should I handle it if there is no activity,
and if I set a timeout in the beginning, → how should I revive this connection to check whether there is a change or not?

Thank you.

Hi @Shay_I ,

We have change stream production consideration :

Additionally, you have all the code snippets and content on how to open and resume change streams on our docs:

If you have more specific questions let me know.

Thanks
Pavel

2 Likes