node:10212[DEP0123]DeprecationWarning:Setting the TLS ServerName to an IPaddress is not permitted by RFC 6066.This will be ignored in a future version

Viewed 6634

Below is my nodejs code to connect to a mssql database and query data

const sql = require('mssql')
export class GetJDBCCasedata {
  async fetchData(wellid, wellboreid, designid) {
    var result
     console.log("In fetchdata")
const sqlConfig = {
  user: 'root',
  password:'root',
  database: 'student',
  server: '12.11.234.12',
 /* pool: {
    max: 10,
    min: 0,
    idleTimeoutMillis: 30000
  },*/
  options: {
    encrypt: true,
    trustServerCertificate: true,
  }
}
console.log("CONFIG FOR SERVER "+JSON.stringify(sqlConfig))
 try {
  console.log("Connecting to database")
  result=await sql.connect(sqlConfig)
  console.log("Connected to database")
 } catch (err) {
  result=err
  console.log("ERROR OCCURRED "+err)
 }
return result
  }
}

The code runs fine and I get the message as "Connected to database". However I get a message as "(node:10212) [DEP0123] DeprecationWarning: Setting the TLS ServerName to an IP address is not permitted by RFC 6066. This will be ignored in a future version." What can I do to get rid of it?

3 Answers

I solved same issue by encrypt:false.

options: {
encrypt: false,
trustServerCertificate: true,
}

I found that if I use the value received from SELECT @@SERVERNAME and I link that up to the IP of the server via the windows hosts file it works and drops the warning.

Related