connect-mongodb-session icon indicating copy to clipboard operation
connect-mongodb-session copied to clipboard

Bubble up 'reconnectFailed' event

Open goliatone opened this issue 7 years ago • 5 comments

I'm getting the following error:

Error finding fik2w7v-AqcYBZZ6ib8SgcL58j44RMoL: Topology was destroyed

I want to reconnect but currently the store creates the connection in the constructor and exposes no method. How are we supposed to handle reconnections?

goliatone avatar Jan 16 '18 16:01 goliatone

Did you pass a callback to the MongoDBStore constructor to catch errors? I'd assume you'd want to handle there.

mckenzieja avatar Dec 03 '18 14:12 mckenzieja

For the initial connection, you might need to do a process.exit() in the constructor's callback and get whatever is running your program to automatically restart it. For subsequent errors it seems like you can pass in something like { connectionOptions: { reconnectTries: Number.MAX_SAFE_INTEGER, reconnectInterval: 1000 }}

eug48 avatar Dec 04 '18 13:12 eug48

@goliatone is this error on initial connection? Or after the store is successfully running?

vkarpov15 avatar Dec 04 '18 21:12 vkarpov15

@vkarpov15 it happens after the app is running for a while.

goliatone avatar Dec 30 '18 23:12 goliatone

Try setting connectionOptions.reconnectTries as @eug48 suggested. Here's an explanation of why this is necessary. In the meantime, I'll keep this issue open because we should probably emit an 'error' event if we get a reconnectFailed event.

vkarpov15 avatar Jan 23 '19 20:01 vkarpov15