I have a REST API (Written with Express + Monk ) connected to MongoDB. The database is a MongoDB replica set setup with mms.
When the primary node goes down the app becomes non responsive. It need a manual restart to work again after the SECONDARY is elected as PRIMARY.
Config :
Mongodb Replica set (Ver 2.6.7) configured with MMS Total three nodes (two data nodes and one arbiter) All default configs as given by MMS Node App : Express with Monk as mongodb driver. (I tried in mongoose as well,same result) Connection string :-
mongodb://xxx1.xxx.com:27017, xxx2.xxx.com:27017: 27017/dbname with option as var options = { server: { socketOptions: { keepAlive: 1, socketTimeoutMS : 15000, connectTimeoutMS: 30000 } }, replset: { socketOptions: { keepAlive: 1, socketTimeoutMS : 15000, connectTimeoutMS: 30000 } } }
Is it related to something I misconfigured? Does it have anything to do with mms? How to fox this?
UPDATE: Steps I followed
Created 3 three new VMs in Azure Cloud and deployed mongodb replica set to it using MMS (One primary, one secondary and one arbiter). Generated a new express app. Added Monk module Write a simple API to connect to the replica set (The API will write something to db, then read it and send back as response) Continuously call this API form a bash script to make sure that the API is up and running restart the machine which is acting as primary The API will keep failing even after a new primary is elected and all VMs are back up.
A sample nodejs code I tested with is available at https://[email protected]/melvingeorge/nodejsmongorssample.git