douhuai2015 2016-07-04 09:08
浏览 59
已采纳

在灵活的环境中将Google App Engine与Google Cloud Storage相连接

I want to connect from my GAE app to my Google Cloud MySQL instance. I am using the github.com/go-sql-driver/mysql driver and I followed the steps specified in the tutorial. Apparently I can connect to the database without an error but when I want to make a request I get driver: bad connection and packets.go:33: unexpected EOF. I authorised both my local IP address and the GAE app to access my database and I can connect to it from my local machine and the mysql client without a problem. I have already tried setting up my app in the standard environment and followed the advice here but it didn't work either.

That is my Go code with which I connect to the database:

host := os.Getenv("DB_HOST")
user := os.Getenv("DB_USER")
pwd := os.Getenv("DB_PWD")
connectionInfo := fmt.Sprintf("%v:%v@tcp(%v:3306)/mobile_data?parseTime=true", user, pwd, host)
db, err := sql.Open("mysql", connectionInfo)

And this is my app.yaml file:

runtime: go
vm: true
env_variables:
    "DB_HOST": "[Google Cloud MySQL Instance IPv4]"
    "DB_USER": "[User]"
    "DB_PWD": "[Password]"

Any tip or advice is greatly appreciated!

  • 写回答

1条回答 默认 最新

  • dongmaoluan5719 2016-07-05 07:18
    关注

    This link states that instance-level access between the app engine flexible environment and a First Generation Cloud SQL instance is not supported yet. If you want to connect to a Second Generation Cloud SQL you would have to use the Cloud SQL Proxy.
    Thanks to @Tianzhou for pointing me to the link.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效