Skip to content
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

Automatic reconnect on db connection interruption #14

Open
coffenbacher opened this issue Feb 28, 2016 · 2 comments
Open

Automatic reconnect on db connection interruption #14

coffenbacher opened this issue Feb 28, 2016 · 2 comments

Comments

@coffenbacher
Copy link

If the connection to the database gets interrupted (e.g. database is restarted), the server seems to crash permanently.

It would be great if the server could reconnect when the connection is available again.

For example, this stacktrace is what happens to the Chat example when the database is restarted (and in perpetuity until the websocket server is restarted).

22:21:18.676 172.17.0.5:54391 Error in sessionCreator
ReqlDriverError: Connection is closed.
    at ReqlDriverError.ReqlError [as constructor] (/app/node_modules/rethinkdb/errors.js:23:13)
    at new ReqlDriverError (/app/node_modules/rethinkdb/errors.js:68:50)
    at TcpConnection.Connection._start (/app/node_modules/rethinkdb/net.js:413:13)
    at /app/node_modules/rethinkdb/ast.js:142:29
    at Get.TermBase.run (/app/node_modules/rethinkdb/ast.js:131:12)
    at AuthManager.js:17:47
    at tryCatcher (/app/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/app/node_modules/bluebird/js/release/promise.js:497:31)
    at Promise._settlePromise (/app/node_modules/bluebird/js/release/promise.js:555:18)
    at Promise._settlePromiseCtx (/app/node_modules/bluebird/js/release/promise.js:592:10)
    at Async._drainQueue (/app/node_modules/bluebird/js/release/async.js:130:12)
    at Async._drainQueues (/app/node_modules/bluebird/js/release/async.js:135:10)
    at Immediate.Async.drainQueues [as _onImmediate] (/app/node_modules/bluebird/js/release/async.js:16:14)
    at processImmediate [as _immediateCallback] (timers.js:383:17)
@mikemintz
Copy link
Owner

Based on that stack trace, and my understanding of the code, I think this is specific to the chat example and other similar examples. It's the connection set up manually in index.js as opposed to the proxied connections that rethinkdb-websocket-server provides.

So before implementing auto-reconnect in rethinkdb-websocket-server, we'd first have to provide an abstraction as opposed to having the application developer manually connect for validations.

I'm not sure yet what the best way to do that is, but it's worth exploring.

In the meantime, I think if developers use rethinkdbdash when connecting from their backend, it provides auto-reconnect out of the box.

@coffenbacher
Copy link
Author

Great, I think rethinkdbdash should solve my immediate issue. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants