Thursday, February 9, 2017

[google-cloud-sql-discuss] Re: Communications Link Failure connecting to MySQL Cloud Instace

Sure - here is how we connect in Java with as much of the log as was output.

Let me know if I can provide any more info, this is becoming a very painful problem for us. 

Thanks!!
Dave


public String ConnectToDb(String host, String user, String password, String dbname) {
try {
Class.forName("com.mysql.jdbc.Driver");
db = DriverManager.getConnection(
"jdbc:mysql://" + host + ":3306/" + dbname + "?user=" + user + "&password=" + password);
} catch (Exception e) {
db = null;
e.printStackTrace();
System.out.println("SQLException: " + e.getMessage());
return e.getMessage();
}
return "success";
}

Exception Caught in Query()SQLException: Communications link failure The last packet successfully received from the server was 3,561 milliseconds ago. The last packet sent successfully to the server was 3,561 milliseconds ago. SQLState: 08S01 VendorError: 0 Feb 09, 2017 1:14:37 PM spaceNavSendMail.Sql queryAggregatePcQuery SEVERE: Error in queryAggregatePcQuery() com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet successfully received from the server was 3,561 milliseconds ago. The last packet sent successfully to the server was 3,561 milliseconds ago. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at com.mysql.jdbc.Util.handleNewInstance(Util.java:377) at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1036) at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3427) at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3327) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3814) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2435) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2582) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2526) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2484) at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1446) at spaceNavSendMail.Sql.queryAggregatePcQuery(Sql.java:3435) at spaceNavSendMail.SpaceNavSendMail.generateEmailMessage(SpaceNavSendMail.java:980) at spaceNavSendMail.SpaceNavSendMail.getConjunctionReport(SpaceNavSendMail.java:897) at spaceNavSendMail.SpaceNavSendMail.sendSummaryEmail(SpaceNavSendMail.java:710) at spaceNavSendMail.SpaceNavSendMail.main(SpaceNavSendMail.java:347) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)Caused by: java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost. at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2914) at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3337)



On Thursday, January 12, 2017 at 9:22:35 AM UTC-7, Dave Greenly wrote:
Hi there, 

We have a Cloud Instance of a MySQL Database which we use daily.  We have multiple compute engines that pull and push data to it, and on those compute engines are Java programs that connect to the database and read/write.

Pretty standard stuff.

On a semi-consistent basis, our Java programs have difficulty connecting to the database, and we receive a "Communications Link Failure" and our code cannot connect to the DB.  After some indeterminate amount of time, things "just start working again".

We actually put a check in our code for this error, and if we get it, we wait a few seconds, and try again, but even after 5 or so retry attempts, sometimes it is still not working.

We have chalked this up in the past to some type of network anomaly going on in the cloud.

We are using mysql-connector-java-5.1.38, and the MySQL instance on the cloud is version MySQL 5.5.

Has anyone else experienced this?

Thanks
Dave

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/1fb5ef88-8593-46a5-b08f-6d84d0fde92a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment