thinky icon indicating copy to clipboard operation
thinky copied to clipboard

how to reconnect to rethink when server disconnects with DB

Open juhaelee opened this issue 9 years ago • 5 comments

I came across a scenario where I was in staging and my server disconnected with rethinkdb (I was unable to make any calls using thinky). Is there a way to watch and reconnect to rethinkdb using thinky after a connection has been lost?

I am using compose.io

juhaelee avatar Feb 23 '16 10:02 juhaelee

It automatically reconnects.

On Tue, Feb 23, 2016, 02:20 juhaelee [email protected] wrote:

I came across a scenario where I was in staging and my server disconnected with rethinkdb (I was unable to make any calls using thinky). Is there a way to watch and reconnect to rethinkdb using thinky?

— Reply to this email directly or view it on GitHub https://github.com/neumino/thinky/issues/448.

neumino avatar Feb 23 '16 16:02 neumino

@neumino Interesting, last night I had to restart my server for it reconnect. I was getting nothing that involved rethinkdb calls. Maybe it was a really random edge case?

juhaelee avatar Feb 23 '16 16:02 juhaelee

I will explain my issue:

I run my NodeJS App development envirement with:

  • SO: Windows 10
  • NodeJS: 4.4.5
  • RethinkDB: 2.3.5-windows
  • Thinky: 2.3.8

I follow the next steps:

  1. Start the rethink database
  2. Start the nodejs application within a windows prompt
  3. Next i check if the app works, making a request, and geting a normal response
  4. Next i shut down the database, closing the promp where the rethinkdb database is running
  5. I try again a request to the app, and get a failure response
  6. Then, i open the database again
  7. I make a new request to the application, and still get a failure response
  8. the prompt where is running the app log the next exception, same exception while the database is offline:
ReqlDriverError: The connection was closed by the other party.
    at Connection._send (C:\html5\fuel4u-api-dev-1\node_modules\thinky\node_modules\rethinkdbdash\lib\connection.js:732:15)
    at C:\html5\fuel4u-api-dev-1\node_modules\thinky\node_modules\rethinkdbdash\lib\term.js:206:22
From previous event:
    at Term.run (C:\html5\fuel4u-api-dev-1\node_modules\thinky\node_modules\rethinkdbdash\lib\term.js:146:15)
    at Query._executeCallback (C:\html5\fuel4u-api-dev-1\node_modules\thinky\lib\query.js:161:22)
    at C:\html5\fuel4u-api-dev-1\node_modules\thinky\lib\query.js:149:17
    at tryCatcher (C:\html5\fuel4u-api-dev-1\node_modules\thinky\node_modules\bluebird\js\main\util.js:26:23)
    at Promise._settlePromiseFromHandler (C:\html5\fuel4u-api-dev-1\node_modules\thinky\node_modules\bluebird\js\main\promise.js:507:31)
    at Promise._settlePromiseAt (C:\html5\fuel4u-api-dev-1\node_modules\thinky\node_modules\bluebird\js\main\promise.js:581:18)
    at Promise._settlePromises (C:\html5\fuel4u-api-dev-1\node_modules\thinky\node_modules\bluebird\js\main\promise.js:697:14)
    at Async._drainQueue (C:\html5\fuel4u-api-dev-1\node_modules\thinky\node_modules\bluebird\js\main\async.js:123:16)
    at Async._drainQueues (C:\html5\fuel4u-api-dev-1\node_modules\thinky\node_modules\bluebird\js\main\async.js:133:10)
    at Immediate.Async.drainQueues [as _onImmediate] (C:\html5\fuel4u-api-dev-1\node_modules\thinky\node_modules\bluebird\js\main\async.js:15:14)
    at processImmediate [as _immediateCallback] (timers.js:383:17)
{ [ReqlDriverError: The connection was closed by the other party.]
  msg: 'The connection was closed by the other party',
  message: 'The connection was closed by the other party.' }

inteliti avatar Dec 12 '16 22:12 inteliti

Can you provide all the logs? Including the one from the pool? It can takes a few seconds/minutes to reconnect.

neumino avatar Dec 17 '16 17:12 neumino

Sorry for late response, but i think i resolved the problem updating my nodejs to the the version 6.9.2 or I did not realize that the reconnection is not done when the database is up again, the reconnection is made to the second or third request that is made to the database.

For now is enough for me, then I will do more tests later and I will comment.

Thankyou for your interest and your time.

inteliti avatar Dec 20 '16 13:12 inteliti