Wednesday, 3 May 2017

How to configure node js datasource.json in aws linux machine

Hi, I've created on sample application with nodejs and loopback. when i tried with "db" memory its working. When i added lb datasource its throwing mysql error. Kindly help me how to solve it.

datasource.json

{
  "db": {
    "name": "db",
    "connector": "memory"
  },
  "mysql": {
    "host": "ec2-52-35-183-50.us-west-2.compute.amazonaws.com",
    "port": "3307",
    "url": "",
    "database": "medola",
    "password":"xxyyxx@123",
    "name": "mysql",
    "user": "root",
    "connector": "mysql"
  }
}

Stacktrace:

Connection fails: Error: connect ECONNREFUSED 172.31.24.147:3307 It will be retried for the next request. events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: connect ECONNREFUSED 172.31.24.147:3307
    at Object.exports._errnoException (util.js:1018:11)
    at exports._exceptionWithHostPort (util.js:1041:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)
    --------------------
    at Protocol._enqueue (/home/ec2-user/medola/node_modules/mysql/lib/protocol/Protocol.js:141:48)
    at Protocol.handshake (/home/ec2-user/medola/node_modules/mysql/lib/protocol/Protocol.js:52:41)
    at PoolConnection.connect (/home/ec2-user/medola/node_modules/mysql/lib/Connection.js:130:18)
    at Pool.getConnection (/home/ec2-user/medola/node_modules/mysql/lib/Pool.js:48:16)
    at MySQL.connect (/home/ec2-user/medola/node_modules/loopback-connector-mysql/lib/mysql.js:89:17)
    at Object.initializeDataSource [as initialize] (/home/ec2-user/medola/node_modules/loopback-connector-mysql/lib/mysql.js:43:28)
    at DataSource.setup (/home/ec2-user/medola/node_modules/loopback-datasource-juggler/lib/datasource.js:352:19)
    at new DataSource (/home/ec2-user/medola/node_modules/loopback-datasource-juggler/lib/datasource.js:121:8)
    at Registry.createDataSource (/home/ec2-user/medola/node_modules/loopback/lib/registry.js:355:12)
    at dataSourcesFromConfig (/home/ec2-user/medola/node_modules/loopback/lib/application.js:440:19)
    at EventEmitter.app.dataSource (/home/ec2-user/medola/node_modules/loopback/lib/application.js:235:14)
    at /home/ec2-user/medola/node_modules/loopback-boot/lib/executor.js:190:9
    at /home/ec2-user/medola/node_modules/loopback-boot/lib/executor.js:281:5
    at Array.forEach (native)
    at forEachKeyedObject (/home/ec2-user/medola/node_modules/loopback-boot/lib/executor.js:280:20)
    at setupDataSources (/home/ec2-user/medola/node_modules/loopback-boot/lib/executor.js:180:3)



via Varathan Swaminath

No comments:

Post a Comment