1

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

fxbayuanggara
  • 316
  • 3
  • 16

1 Answers1

2

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
Rodrigo López Dato
  • 1,144
  • 6
  • 13
  • Okay thanks for your help.. Its help me a lot, and I discovered that the problems is belong to my hosting services that doesn't allowed my database being accessed by public ip(s). Right now I tried to change my service and I will inform you whether its works or not. Thanks – fxbayuanggara May 26 '15 at 17:30
  • Hey Rodrigo, I've succeed connecting my MySql database server to Auth0. When I try the "create script" it saves the data in my Database. But there was a thing that bothered me, when I try the create Api -> POST https://myapp.auth0.com/api/users/ .. its always fail and shows errors : "Users API - Status Code: 500", but the data are saved in my database. What do you think about this? – fxbayuanggara May 27 '15 at 19:22
  • Could you send the full script and error message to support@auth0.com? I can follow up there. This isn't really the correct place to continue this discussion. Thanks! – Rodrigo López Dato May 27 '15 at 22:05
  • hey.. it has been solved, my bad.. I have choose a wrong back-end services for my app-API. Thanks!.. – fxbayuanggara May 28 '15 at 06:53
  • Hi @data. I got same problem here and I not clearly understand your solution. Can you give me an exactly example to connect to mysql server with auth0? – eugene Dec 15 '16 at 08:54