Home > Blockchain >  Use multiSubnetFailover in sequelize and mssql packages
Use multiSubnetFailover in sequelize and mssql packages

Time:02-25

I have a backend application (Node.JS) that uses mssql (v7) and sequelize (v6) npm packages.

Since my production DB configuration is (and can be only) accessed by an AGL, hence I need to set multisubnetfailover=true in the DB connection string.

Although support for this existed in previous versions, I am unable to find the same in the current stable versions of the respective packages. (Here's a sample code for previous sequelize and mssql version)

Is there a way to enable this in the newer version?

CodePudding user response:

For sequelize (v6):

Solution:

...existing sequelize configuration
dialect: "mssql",
dialectOptions : {
   options: {
    multiSubnetFailover: true,
   }
}
...

Approach: I was looking at the source code links sent by @AlwaysLearning in the comments above, and found that, if multiSubnetFailover's value is not a boolean, an error is thrown.

I then updated my configuration to dialectOptions.multiSubnetFailover : "1234", however I did not get the TypeError I was expecting. Then I looked at some more code and found that multiSubnetFailover should be used inside dialectOptions.options.

For mssql (v7):

Got help from a contributor.

...existing mssql configuration
options: {
      multiSubnetFailover: true,
    }
...

Cheers!

  • Related