Skip to content

App Engine and Cloud SQL - connection lost issue #163

Description

@martinmicunda

Hi,

I have forked the appengine/cloudsql project and deployed to google cloud however I am getting follow error Connection lost: The server closed the connection. each time I deploy the app. I am able to run application on my local machine using cloud_sql_proxy without any problem so it seems the issue is somewhere between app engine and cloud sql as Mysql connection is always dropping..

In app.yaml I am using follow MYSQL_SOCKET_PATH: /cloudsql/[YOUR_PROJECT_ID]:[YOUR_REGION]:[YOUR_INSTANCE_NAME]

Are there any changes in configuration or doc that I am missing?

P.S.: I am using second generation of Cloud SQL.

Thanks,
Martin

Activity

  1. jmdobry commented on Aug 10, 2016

    @jmdobry
    Member

    Can you post the exact contents of app.yaml?

  2. martinmicunda commented on Aug 10, 2016

    @martinmicunda
    Author

    The Connection lost: The server closed the connection error means that at least credentials are correct otherwise I would see ENOENT or access denied error message so there might be something wrong with socket.

    runtime: nodejs
    vm: true
    
    env_variables:
      MYSQL_USER: [YOUR_USER]
      MYSQL_PASSWORD: [YOUR_PASSWORD]
      MYSQL_DATABASE: [YOUR_DATABASE]
      MYSQL_SOCKET_PATH: /cloudsql/[YOUR_PROJECT_ID]:[YOUR_REGION]:[YOUR_INSTANCE_NAME]
    
    beta_settings:
      cloud_sql_instances: [YOUR_PROJECT_ID]:[YOUR_REGION]:[YOUR_INSTANCE_NAME]
  3. jmdobry commented on Aug 10, 2016

    @jmdobry
    Member

    You need to replace all of the variables with your actual values, e.g. [YOUR_PROJECT_ID] => my-project, [YOUR_USER] => my-user-name, etc.

  4. martinmicunda commented on Aug 10, 2016

    @martinmicunda
    Author

    I know :) so let's assume [YOUR_PROJECT_ID] is name of your project id that you can get from Cloud SQL console then app.yaml looks like this:

    runtime: nodejs
    vm: true
    
    env_variables:
      MYSQL_USER: root
      MYSQL_PASSWORD: pass
      MYSQL_DATABASE: test1
      MYSQL_SOCKET_PATH: /cloudsql/[YOUR_PROJECT_ID]:us-central1:test
    
    beta_settings:
      cloud_sql_instances: [YOUR_PROJECT_ID]:us-central1:test
  5. jmdobry commented on Aug 10, 2016

    @jmdobry
    Member

    I just successfully deployed the Cloud SQL sample to https://sql-dot-nodejs-docs-samples.appspot.com/ using:

    runtime: nodejs
    vm: true
    env_variables:
      MYSQL_USER: myuser
      MYSQL_PASSWORD: mypassword
      MYSQL_DATABASE: nodejs-docs-samples
      MYSQL_SOCKET_PATH: /cloudsql/nodejs-docs-samples:us-central1:nodejs-docs-samples
    beta_settings:
      cloud_sql_instances: nodejs-docs-samples:us-central1:nodejs-docs-samples

    Assuming you've made no alterations to the sample and you've already successfully connected to your Cloud SQL instance from your local computer to verify that your test1 database exists, then I don't know what the problem could be. I'll have to open an issue.

  6. martinmicunda commented on Aug 10, 2016

    @martinmicunda
    Author

    I found where the problem was. I had to enable the Cloud SQL Administration API and everything works fine now. Thanks for help ;)

  7. jmdobry commented on Aug 11, 2016

    @jmdobry
    Member

    Ah, I didn't think of that.

  8. added a commit that references this issue on Nov 7, 2022
  9. added a commit that references this issue on Nov 11, 2022
  10. added a commit that references this issue on Nov 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    🚨This issue needs some love.triage meI really want to be triaged.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions