nodejs sequelize connect to a remote mySQL database always give ETIMEDOUT - mysql

i need your help regarding connecting sequelize to a remote mySQL database
sequelize connects fine when i set host attribute to 'localhost' like this:
new Sequelize('billsmanager', 'root', '12345', {
host: `localhost`,
dialect: 'mysql',
define: {
timestamps: false
},
pool: {
max: 25,
min: 0,
idle: 10000
},
})
then i've tried to put my local IP address at home instead of 'localhost' and ETIMEDOUT comes
i tried freeinfinity hosting site it gives ETIMEDOUT
my office server it gives ETIMEDOUT
even i tried my brother's home server and it gives me ETIMEDOUT
and even my network at home it gives ETIMEDOUT
someone suggested here to add inbound rule in firewall for port 3306 and it doesn't work
and commenting bind-address in my.ini didn't work too
i'm using XAMPP
i don't know really why this happens
can you help me?
thanks so much in advance,i really need this to work

i've solved it at last with very silly solution
i added a connect timeout to 100Sec and it worked and connected after like 12Sec
i wrote the initialization like this:
sequelizer: new Sequelize('billsmanager', 'root', '12345', {
host: `192.168.1.2`,
dialect: 'mysql',
dialectOptions: {
connectTimeout:100000
},
define: {
timestamps: false
},
pool: {
max: 25,
min: 0,
idle: 10000
},
}),
thanks

Related

KnexTimeoutError: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?

I'm working on a project. Today I started getting this error: "KnexTimeoutError: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?".
I've seen another post here on stackoverflow, that this is a problem with NODE14 and knex < 8.0.3. I'm not using this version, so I don't understand where this error is coming from? Here's some relevant info:
"dependencies": {
"knex": "^0.95.13",
"mysql": "^2.18.1",
"next": "12.0.3",
"react": "17.0.2",
"react-dom": "17.0.2"
}
Here is some relevant code:
knexFile.js
module.exports = {
development: {
client: 'mysql',
connection: {
host: '127.0.0.1',
port: 3000,
user: process.env.MYSQL_USERS,
password: process.env.MYSQL_PASSWORD,
database: process.env.MYSQL_DB,
},
debug: true,
pool: {
max: 50,
min: 2
},
}
};
Can someone help me with this issue? The error comes and goes and I don't know how to solve this. Thanks!

lando - mysqldump: Got error: 2002: Can't connect to local MySQL server

I am trying to exporting database via lando command which is documented on
https://docs.lando.dev/config/drupal8.html#connecting-to-your-database
lando db-export database_backup.sql
mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/opt/bitnami/mysql/tmp/mysql.sock' (111) when trying to connect
Failed to create file: /app/database_backup.sql
Here is lando info
service: 'database',
urls: [],
type: 'mysql',
internal_connection: {
host: 'database',
port: '3306'
},
external_connection: {
host: 'localhost',
port: '32807'
},
creds: {
database: 'drupal8',
password: 'drupal8',
user: 'drupal8'
},
It looks like your MySQL server does not work properly.
lando rebuild
should fix it.

Node Sequelize cannot connect to MySQL SSL

I'm trying to connect my node app to my remote MySQL server and I am getting the following error:
Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'remoteUser'#'mysqlIpAddress' (using password: YES)
However, I can connect to the mysql server just fine by using the following command.
mysql -u remoteUser -h 138.68.15.94
Here is my connection string
sequelize = new Sequelize(config.mysql.database, config.mysql.user, config.mysql.password, {
host: config.mysql.host,
dialect: 'mysql',
ssl: true,
dialectOptions: {
ssl: true
},
define: {
timestamps: false
},
pool: {
max: 5,
min: 0,
idle: 10000
},
})
Any help would be great! I've been fighting this the past two days.

sequelize mysql ssl SequelizeConnectionError: ER_HANDSHAKE_ERROR: Bad handshake

I try to connect to an Azure MySQL DB with ssl.
new Sequelize('db', 'user', 'pw',
{
host: '...',
port: '3306',
dialect: 'mysql',
dialectOptions: {
insecureAuth: true,
ssl: {
ca: fs.readFileSync('ca.pem')
}
}
}
However I get ... `
SequelizeConnectionError: ER_HANDSHAKE_ERROR: Bad handshake
I have already tried:
https://github.com/sequelize/sequelize/issues/578
`
Ensure that your credentials are in the format of user#servername; this is required for Azure Database for MySQL.
A little late to the party but just came across this myself. This thread helped me solve it. If it's an option you could also just downgrade your version of Node but that's more of a bandaid than a fix.

How to connect Node Sequelize to Amazon RDS MySQL with Multi-AZ probably

I'm using an Amazon RDS hosted MySQL with Multi-AZ Support. Just could not find any information on how to connect Sequelize to Amazon RDS properly so that Sequelize is handling fail-overs etc. accordingly?
I'm just using the following config, but do not know if this is enough or recommended?
sequelizeConfig = {
logging: false,
pool: { maxConnections: 5, maxIdleTime: 30},
sequelizeConfig[dialectOptions] = {
ssl: 'Amazon RDS'
}
}
Using Amazon RDS with Multi-AZ I consider the following is important:
Try reconnecting if connection got lost, until it is available again
Don't cache mysql server ip address too long (Amazon suggests less than 1 min)
Amazon Docs are not writing anything about connection handling and pooling.
Here is how i got connected with my RDS:
var config = require(__dirname + '/../config/config.json')[env];
// your config file will be in your directory
var sequelize = new Sequelize(config.database, config.username, config.password, {
host: '****.****.us-west-1.rds.amazonaws.com',
port: 5432,
logging: console.log,
maxConcurrentQueries: 100,
dialect: 'postgres',
dialectOptions: {
ssl:'Amazon RDS'
},
pool: { maxConnections: 5, maxIdleTime: 30},
language: 'en'
})
The previous answer didn't work for me, after some research, this options object did:
var options = {
host: settings.database.host,
port: settings.database.port,
logging: console.log,
maxConcurrentQueries: 100,
dialect: 'mysql',
ssl: 'Amazon RDS',
pool: { maxConnections: 5, maxIdleTime: 30 },
language: 'en',
}
I'm running a RDS MySQL and a EC2 instance in the same default VPC, this options object worked when connecting a node app from that EC2 with the RDS using sequelize.