Search code examples
mysqlionic-frameworkmulti-device-hybrid-appsauth0

How to configure custom database Mysql in Auth0 Connection?


I'm using auth0 as my authentification services into my project. I really love it, but I have a problem when using custom database(MySql), I sure that I have configured the db.connection parameter to my remote shared hosting database in Plesk. It always show : "[Error] Script execution did not complete within 20 seconds. Are you calling the callback function?", When I trying to run "Create" script. here the script :

function create (user, callback) {
var mysql      = require('mysql');
var connection = mysql.createConnection({
host     : '192.168.23.16',    
user     : 'user',
password : 'pass',
port     : '3306',
database : 'dbname' });
connection.connect();
var query = "INSERT INTO users SET ?";
var insert = { 
password: bcrypt.hashSync(user.password, 10),
email:    user.email
};
connection.query(query, insert, function (err, results) {
if (err) return callback(err);
if (results.length === 0) return callback();
callback(null);
});
}

What should I'm doing right now to solve this problem? I'm new to this Thanks.. Regards, fxbayuanggara


Solution

  • You're trying to connect to a local IP address (192.168.23.16), which will always fail since database scripts and rules are executed from Auth0's servers. You'll need to make your MySQL server accessible from Auth0's IP addresses, which at the time of writing are the following:

    • US domains: 138.91.154.99, 54.221.228.15, 54.183.64.135, 54.67.77.38, 54.67.15.170, 54.183.204.205, 54.173.21.107, 54.85.173.28
    • EU domains: 52.28.56.226, 52.28.45.240, 52.16.224.164, 52.16.193.66