-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do I handle reconnections? #34
Comments
If you are able to provide a snippet of your code, that would give us a better idea. You can make one as an example if you do not wish to share sensitive code. but just to understand where the problem is originating. You can create a template that spawns upon that error and asserts the application's connection to a socket. But that's just a guess. If you could provide a little more information I'd be happy to take a look when I get the chance. |
@samsamros Thanks for the quick response! I am compiling with the debug flag and this is the stacktrace I received. I pushed up a repo to hopefully make it easy to reproduce the issue. You can find it here: https://github.com/danbarbarito/anonimongo-reconnection-issue All you should need to do is create a new Also, the implementation of the |
I'll take a look as soon as I can! something like this (but in your case the mongoClient): var
localcol* {.threadvar.}: Collection[AsyncSocket] you can initialize the object from the global variable, and it will take those values into the thread's scope. You can also redefine the variable, but only within that thread's scope. I will try to take a look at your code and see where the problem is arising. |
Just curious - any updates on this one? |
What is the best way to handle reconnections when the connection gets lost? I'm trying to use this library with Prologue. When the connection gets lost, I see an error message like this:
The connection does not appear to attempt to reconnect on its own, so I have to restart my application to get everything working again.
I am using MongoDB Atlas Cloud and to test this issue I am forcefully disconnecting my open connection by going to the Security > Network Access page and removing my IP address. Once the application starts throwing the above error, I add my IP address again. The error persists until I restart the application. If this library does not do reconnections, I assume I would need to manually re-run the
connect
andauthenticate
functions again in response to this exception, but I don't know where to add that logic in a typical Prologue application.What is the best way to fix this? How should I catch and handle this exception in a typical Prologue application?
The text was updated successfully, but these errors were encountered: