-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Google Cloud SQL on App Engine - Connection String Outdated? #484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
user@cloudsql(project-id:instance-name)/dbname Recently gae started categorising the database into regions too hence the new format. If your cloudsql is categorised into a region, you'll need to use the new format |
Perhaps this driver doesn't properly parse the new format. That may be the issue |
In your case, are you running a second generation Cloud SQL server? |
No first gen |
I suspect the driver isn't parsing the new format. The code may need to change so that it takes the content before first colon and the content after first colon irrespective of the new colon present |
There is a pull request currently updating read me |
Thanks for the heads up. I just left a comment on that PR. |
Update: It looks like there is an issue with the driver when a deployed Google App Engine application tries to connect to a second generation Google Cloud SQL Server. I created a first generation Cloud SQL Server and I was able to successfully connect to the server using a deployed Google App Engine application with this connection string:
No region name was required. |
Parsing shouldn't be a problem, the driver takes everything between the parens: https://github.com/go-sql-driver/mysql/blob/master/dsn.go#L282 Can someone with a cloudsql account please download the driver, edit https://github.com/go-sql-driver/mysql/blob/master/appengine.go#L14 and replace |
_Guys, for reference:_ Google's posted documentation was (and perhaps still is) wrong, but the correct solution is posted there. We're using 2nd generation Cloud SQL in production without issue. |
Is there a solution to this? Definitely not working with CloudSQL Second Generation. |
@bagatelli see my comment above yours |
@benguild I've seen your comment in multiple places. However you're assuming that everyone is using SSL in their connections which is not the case to everyone. Certainly it's not mine. The error message I'm getting is "Driver: Bad Connection". The database is not even reached because the driver can't identify the connection parameters properly. I'm thinking the issue lies somewhere in the mess that's been around with the "new appengine" and "old appengine" packages which is causing a lot of things to break and Google is not bothering to document this change properly. |
@bagatelli To clarify, make sure you're using the connection string format mentioned in this comment: http://stackoverflow.com/questions/38890022/tls-requested-but-server-does-not-support-tls-error-with-google-cloud-sql-2nd#comment65140499_38890022 Sorry for the prior brevity. We're using 2nd gen in production from Go on App Engine without issue. Just leave out the "tlsConfigName" parameter since the SQL proxy will add that, but either way they report that TLS is now supported anyway. |
@benguild . Thanks for all your effort in helping me out on all these issues. |
@bagatelli If you're having trouble deploying, try pulling your code onto a VM or use Google Cloud Console. |
@bagatelli What I was saying was... to try it on a fresh machine, or use their cloud console (which has the dev tools already) before you write off the fact that it's definitely not environment related. I can't currently deploy using macOS Sierra due to a bug that's 4 months old, but we can deploy fine from an VM. I'm sure it's more work for you to move off the environment entirely so I'd at least be sure to rule that out before quitting entirely. |
@pjebs . Not sure where you've got this assumption from but I'm not using flexible environment. |
@pjebs That's incorrect. That's currently how you deploy to standard. |
@pjebs |
@bagatelli I hear you— I generally tend to minimize my third-party dependencies and also API dependencies since what you're saying is true... Google is not obligated to provide support, although they'd risk their reputation otherwise. I'm not sure what's currently the issue for you exactly (besides using old APIs, I think?), but every piece of software I've developed for App Engine I've also developed with the intention of moving off of App Engine if and when needed. For example, for every Google API I interface with, I write a "helper" for that actually calls the methods and provides its own to the rest of the application so that and only that needs to be adjusted to a new environment when necessary and [hopefully] without breaking the rest of the application. For me, App Engine is more of a convenience as it's an environment that requires little configuration besides for scaling and preferences, and provides some great APIs. It's annoying when something goes wrong, but they do offer premium support if you have issues like what you're talking about? |
@pjebs. As fas as I understand goapp is just a wrapper for appcfg.py. It will end up calling appcfg.py at some point. |
@bagatelli Sure, send me an email. No problem |
@benguild . I've finally managed to deploy my app, however still no luck connecting to CloudSQL.
Still no luck. Error:
@arnehormann . This answers your question from your post above. |
@bagatelli Try it without TLS. |
@benguild . Tried without tls. No luck. Driver: Bad Connection @pjebs . Not sure if you fully understand the issue here. The driver is not even reaching the database. I do understand what you've mentioned above may be true on a production environment but I'm not even able to establish a single connection to the database so in my case the above does not apply at all. |
@bagatelli What I would do is post on Stack Overflow like I did and tag it with: If you're having this issue then they'd want to have it indexed for others who have the same issue. Respond back here with a link to the question once resolved. Most likely it still has to do with your implementation because like I said people are using 2nd generation in production and it's out of beta. |
@bagatelli Did you remember to turn off the "TLS Required" setting for the instance in the Cloud Console? |
@benguild . I can't see any mention to TLS in the Cloud Console |
I think you mean the "Allow only SSL Connection". If this is what you're talking about then yes, it's off. |
Ok guys, I've found the issue. And it was neither the driver, my app or CloudSQL. The project I'm deploying the app onto was create many years ago through the old developers console. Thanks again! |
Yeah, if App Engine doesn't have access to the SQL instance then you're going to have a problem. 👍🏻 |
Fixed by #485 |
All I can say is thanks @benguild ! You helped me stop banging my head against the keyboard after 500 open chrome tabs and 5 hours of googling! Hallelujah!!! |
Issue description
In the readme for this driver, the connection string for connecting to Google Cloud SQL on App Engine is given as:
user@cloudsql(project-id:instance-name)/dbname
While Google's cloudsql package documentation also affirms this for your driver, there are posts on Stack Overflow such as this one which claim that one needs to use
projectid:regionname:instancename
rather thanprojectid:instancename
.What is the correct connection string? Neither of these is currently working.
Example code
A more detailed post can be found here: http://stackoverflow.com/questions/39668672/trouble-connecting-to-google-cloud-sql-server-from-deployed-app
Error log
My server is returning a 500 response whenever I make a call to an endpoint that uses the Cloud SQL database. The database connection works fine when I am connecting to the server from a locally served version of my app.
I have tried a variety of connection strings, and here are some errors that were logged in the Google Cloud Console:
(No password was specified in the connection string because the documentation does not specify the need for a password. This post mentions that the connection password must be null when the app attempts to connect to the server using
root@localhost
.)I also tried connecting with a user other than the root user (username: newuser):
Configuration
Driver version (or git SHA): https://github.com/go-sql-driver/mysql/tree/3654d25ec346ee8ce71a68431025458d52a38ac0
Go version: go version go1.6.2 linux/amd64
Server version: The Google Cloud SQL instance is running MySQL 5.7
Server OS: From the Compute Engine tab, it looks like the server hosting the most recent version of my app is running Debian 7.11 (Wheezy)
The text was updated successfully, but these errors were encountered: