Closed anshap1719 closed 5 years ago
Hi @anshap1719 not sure if you figured this out already. When Next
returns false you can call it again if cs.Timeout()
returns true. Here is an example.
There is also MaxAwaitTimeMS
on the options if you don't want it to time out so quickly.
Some other things to consider are calling Close
on the change stream if it didn't time out. And possibly saving the cs.ResumeToken
in case you need to resume a broken stream without losing events.
@rwynn thanks a lot for helping out! @anshap1719 I'll close this issue now.
Cheers, Esther
What version of MongoDB are you using (
mongod --version
)?What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?What did you do?
Here's the code I used to watch for changes and push the result to a go channel:
This channel recieves the value and pushes it to client via websocket. That part is working fine. But the for loop doesn't stay open for even a few seconds.
Any way to keep the cursor open until an error occurs or the server closes?