Socket operation timed out while running Mysql query in GAE local dev

0 views
Skip to first unread message

Sarah Northway via StackOverflow

unread,
Aug 23, 2015, 5:23:07 PM8/23/15
to google-appengin...@googlegroups.com

I'm trying to debug a local Java Google App Engine against a local MySQL database. This is a job that runs once a day, performs a series of selects and crunches the data. In production it uses a cron job against a backend GAE instance and Cloud SQL - no issues.

Locally, I'm running it against a MySQL database (Vertrigo, Win 8). The first two queries are successful but I get a timeout on the third query after a couple seconds. It takes 20 seconds to execute the third query via phpmysql.

My code:

// local debug connection info
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://127.0.0.1:3306/mydb?user=myuser&password=mypass";
Connection conn = DriverManager.getConnection(url);

PreparedStatement stmt1 = conn.prepareStatement("SELECT stuff FROM table1");
ResultSet results1 = stmt1.executeQuery();
... crunch and deal with results1 ...

PreparedStatement stmt2 = conn.prepareStatement("SELECT stuff FROM table2");
ResultSet results2 = stmt2.executeQuery();
... crunch and deal with results2 ...

PreparedStatement stmt3 = conn.prepareStatement("SELECT stuff FROM table3");
ResultSet results3 = stmt3.executeQuery();

It dies on stmt3.executeQuery() with this exception:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 5,327 milliseconds ago.  The last packet sent successfully to the server was 5,003 milliseconds ago.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    ...
Caused by: java.net.SocketException: Socket operation timed out: The API call remote_socket.Receive() took too long to respond and was cancelled.
    at com.google.appengine.api.socket.SocketApiHelper.makeSyncCall(SocketApiHelper.java:76)
    ...

Is this a mysqld configuration issue or something like a socket setting I have to define in Java? I've added these to my.ini and confirmed the new values in phpmyadmin:

[mysqld]
bind-address=127.0.0.1
wait_timeout = 28800
interactive_timeout = 28800
net_read_timeout = 28800
net_write_timeout = 28800


Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/32171655/socket-operation-timed-out-while-running-mysql-query-in-gae-local-dev
Reply all
Reply to author
Forward
0 new messages