AppEngine gets "Communication link failure" error while trying to connect to Google Cloud MySql instance

242 views
Skip to first unread message

Daniel Bouenos

unread,
Apr 27, 2020, 3:08:01 AM4/27/20
to Google App Engine
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. 
the error I am getting in the GCP debug console:
"Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server."

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;
    }



Olu

unread,
Apr 27, 2020, 10:21:22 AM4/27/20
to Google App Engine
Firstly, since connecting using TCP connection with JDBC is not supported on App Engine Standard[1], I assume your application is in an App Engine flexible environment. 

From the snippet of your code shared, I really do not see anything wrong with your implementation, it seems no different from the sample code shared on this page[2--See the Java section]. As you may already know, there are quite a number of reasons why a Communications link failure would be returned from a DB, which includes running out of memory resource and wrong information about the DB. This Stackoverflow thread[3] discusses different possibilities, keeping in mind that CloudSQL is only a Google-Managed mySQL product. 

For better troubleshooting of the issue, which may involve reviewing configurations on your Project, I recommend you contact the GCP Support Engineers[4] or if you think this issue is a bug and you are using the appropriate User account but it is failing, then open an issue using this link[5].

Reply all
Reply to author
Forward
0 new messages