JonRed
JonRed

Reputation: 2981

Unable to make MySql connection with LoopBack

I've been following the Loopback tutorial at https://docs.strongloop.com/display/public/LB/Connect+your+API+to+a+data+source

As per the docs, I have the following server/datasources.json

{
  "db": {
    "name": "db",
    "connector": "memory"
  },
  "mysqlDs": {
    "name": "mysqlDs",
    "connector": "mysql",
    "host": "demo.strongloop.com",
    "port": 3306,
    "database": "demo",
    "username": "demo",
    "password": "L00pBack"
  }
}

My server/model-config.json has the following info

{
  ...
  "CoffeeShop": {
    "dataSource": "mysqlDs",
    "public": true
  }
}

And I've minimised the server/boot/create_sample_model.js to:

module.exports = function(app) {
  app.dataSources.mysqlDs.automigrate('CoffeeShop', function(err) {
    console.log(err.message);   
  });
};

This outputs: Web server listening at: http://0.0.0.0:3000 Browse your REST API at http://0.0.0.0:3000/explorer { [Error: Query inactivity timeout] code: 'PROTOCOL_SEQUENCE_TIMEOUT', fatal: true, timeout: undefined } { [Error: Query inactivity timeout] code: 'PROTOCOL_SEQUENCE_TIMEOUT', fatal: true, timeout: undefined } Query inactivity timeout

I'm not entirely sure where to go next. I've tried installing my own mysql instance, creating a db and using that - but I get the exact same error. Any clues much appreciated. I'm assuming it's a "Stupid User Error" given I'm having an issue with the tutorial :-(

Upvotes: 0

Views: 1103

Answers (1)

JonRed
JonRed

Reputation: 2981

I've got to the bottom of this. There is a regression bug in Node v 4.2.0.

See: https://github.com/felixge/node-mysql/issues/1236

As per these notes, I've updated to v4.2.1 and it's working fine.
Hopefully this helps someone else.

Upvotes: 1

Related Questions