繁体   English   中英

AppEngine 在尝试连接到 Google Cloud MySql 实例时出现“通信链路故障”错误

[英]AppEngine gets “Communication link failure” error while trying to connect to Google Cloud MySql instance

I have a Java/Jetty based appengine project that successfully connects to Google cloud MySql server when using TCP connection with JDBC, BUT fails to connect to the same server when trying to make it through Instance name and JDBC socketFactory. 我在 GCP 调试控制台中遇到的错误:

“通信链路故障最后一个成功发送到服务器的数据包是 0 毫秒前。>驱动程序没有收到来自服务器的任何数据包。”

try {
            Class.forName("com.mysql.jdbc.GoogleDriver");
            String url= String.format("jdbc:google:mysql:///"
                    + "MY_DB_NAME" + "?"
                    + "cloudSqlInstance=%s&"
                    + "socketFactory=%s&"
                    + "useSSL=false",
                    "PROJECT-ID:ZONE:INSTANCE_NAME", 
                    "com.google.cloud.sql.mysql.SocketFactory");

            return DriverManager.getConnection(url, USER_NAME, USER_PASSWORD);
        } catch (SQLException | ClassNotFoundException e) {
            e.printStackTrace();
            return null;
        }

问题可能出在您在云 mysql 实例中指定的公共 IP 地址中。 只需通过键入我的公共 IP 是什么来检查公共 IP 地址即可? 在浏览器中。 然后更新为谷歌云实例提供的公共 IP。 这可能有助于解决您的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM