0

I want to host my application based on node.js and MySql database. I try heroku hosting. I've create an application and add ClearDB add-on with Punch DB plan. The main restriction of this add-on that I cannot create any user-defined functions and events in this plan. It is sopported for expensive database plans.

Then I host my db on Google Cloud SQL. It allows to create user-defined functions and events. However I cannot access to the database from my heroku app because I don't know how to authorize external heroku network for my google cloud database. How can I do this?

Or may be there are any other hostings for NodeJS + MySql application where there are no the restrictions mentioned above?

Dmitriy
  • 683
  • 2
  • 13
  • 26

2 Answers2

1

You should be able to:

a) Use Cloud SQL by authorizing the external IP of your Heroku dyno via a proxy service like QuotaGuard Static or Proximo;
b) Do the same using Amazon RDS.

Additional details that may help:
1. SO question related to QuotaGuard

To clarify: you have to use a third-party add-on like this because Heroku won't guarantee a single IP or even a range of IPs for your dyno.

Community
  • 1
  • 1
brennebeck
  • 450
  • 4
  • 11
0

I add QuotaGuard Static add-on and it holds two ip adresses. Than I add this addresses to the Authorized Networks of my Google Cloud Sql. After then I try to connect to tha database using a guide. Here is my code:

exports.getConnection = () ->
    dbConnParams =
        host: 'google cloud sql ip'
        port: 3306

    proxy = url.parse process.env.QUOTAGUARDSTATIC_URL
    auth = proxy.auth;
    username = auth.split(":")[0]
    pass = auth.split(":")[1]

    sock_options =
        host: proxy.hostname
        port: proxy.port
        user: username
        pass: pass

    sockConn = new SocksConnection dbConnParams, sock_options
    dbConnection = mysql.createConnection({
        user: 'root',
        password: 'pwd',
        stream: sockConn
    });

    return dbConnection

However I obtain an error: "connect ECONNREFUSED". Whats wrong with this approach?

Divya Bhaloidiya
  • 5,018
  • 2
  • 25
  • 45
Dmitriy
  • 683
  • 2
  • 13
  • 26
  • Just to be sure, you basically [did this](https://developers.google.com/cloud-sql/docs/access-control#appaccess) with the QuataGuard IPs, right? Also, have you tried just connecting to CloudSQL via `mysql`(or Workbench, or whatever) on your local machine? – brennebeck Sep 04 '14 at 10:58
  • And have you tried using port `1080` as the `sock_options.port`? – brennebeck Sep 04 '14 at 11:03
  • @brennebeck Yes, I did a steps you are referenced. I've tried to connect via Workbench - it connects successfully. However I haven't tried using 1080 port. I'll try it today. – Dmitriy Sep 04 '14 at 11:14
  • I've try to use port 1080 but still get the same error ECONNREFUSED – Dmitriy Sep 05 '14 at 06:43
  • I'll try to replicate your issues later tonight. I noticed in the CloudSQL docs it mentioned you need to update the password for the root account if you use that, it's a stretch that you didn't do it, but just to confirm: you did update it, yes? – brennebeck Sep 05 '14 at 10:16
  • Actually I don't exact remember how I set a password for my database. Today I'll try to change them. However I still can connect to my db via Workbench. I suppose it won't be possible if I have wrong access configuration. – Dmitriy Sep 05 '14 at 11:14