title: Communications link failure - last packet successfully received from the server was
body: <p>I know this question has been asked before and there are plenty of solutions, but none of them worked for me and it is a bit different in my case.</p>
  
  <p>I have a server with a databases which tunneled to other servers. The servers that run ubuntu 1310 and 1204 don't have any issues. But with the same setup, the same configs, the same application, I get this issue on 1404.</p>
  
  <p>Server Setup:</p>
  
  <pre><code>A - Ubuntu 1204 Server with MariaDB 10.0 Database
    B - Ubuntu 1204 Server with MariaDB 5.5 Client -&gt; tunneled via autossh 14c and works perfect
    C - Ubuntu 1204 Server with MariaDB 5.5 Client -&gt; tunneled via autossh 14c and works perfect
    D - Ubuntu 1310 Server with MariaDB 5.5 Client -&gt; tunneled via autossh 14c and works perfect
    E - Ubuntu 1310 Server with MariaDB 5.5 Client -&gt; tunneled via autossh 14c and works perfect
    F - Ubuntu 1310 Server with MariaDB 5.5 Client -&gt; tunneled via autossh 14c and works perfect
    D - Ubuntu 1404 Server with MariaDB 5.5 Client (also tried mysql 5.5 and mariadb 10.0) -&gt; tunneled via autossh 14c DOES NOT WORK though same setup and app:
  </code></pre>
  
  <p>.</p>
  
  <pre><code>2014-07-11 16:02:51 [SEVERE] com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
  
  The last packet successfully received from the server was 141 milliseconds ago.  The last packet sent successfully to the server was 0 milliseconds ago.
  2014-07-11 16:02:51 [SEVERE]    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  2014-07-11 16:02:51 [SEVERE]    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
  2014-07-11 16:02:51 [SEVERE]    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  2014-07-11 16:02:51 [SEVERE]    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
  2014-07-11 16:02:51 [SEVERE]    at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
  2014-07-11 16:02:51 [SEVERE]    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1116)
  2014-07-11 16:02:51 [SEVERE]    at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3082)
  2014-07-11 16:02:51 [SEVERE]    at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2968)
  2014-07-11 16:02:51 [SEVERE]    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3516)
  2014-07-11 16:02:51 [SEVERE]    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1986)
  2014-07-11 16:02:51 [SEVERE]    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2140)
  2014-07-11 16:02:51 [SEVERE]    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2620)
  2014-07-11 16:02:51 [SEVERE]    at com.mysql.jdbc.ConnectionImpl.setAutoCommit(ConnectionImpl.java:5022)
  2014-07-11 16:02:51 [SEVERE]    at sun.reflect.GeneratedMethodAccessor85.invoke(Unknown Source)
  2014-07-11 16:02:51 [SEVERE]    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  2014-07-11 16:02:51 [SEVERE]    at java.lang.reflect.Method.invoke(Method.java:606)
  2014-07-11 16:02:51 [SEVERE]    at org.apache.tomcat.jdbc.pool.ProxyConnection.invoke(ProxyConnection.java:126)
  2014-07-11 16:02:51 [SEVERE]    at org.apache.tomcat.jdbc.pool.JdbcInterceptor.invoke(JdbcInterceptor.java:109)
  2014-07-11 16:02:51 [SEVERE]    at org.apache.tomcat.jdbc.pool.DisposableConnectionFacade.invoke(DisposableConnectionFacade.java:80)
  2014-07-11 16:02:51 [SEVERE]    at com.sun.proxy.$Proxy76.setAutoCommit(Unknown Source)
  2014-07-11 16:02:51 [SEVERE]    at me.botsko.prism.actionlibs.RecordingTask.insertActionsIntoDatabase(RecordingTask.java:174)
  2014-07-11 16:02:51 [SEVERE]    at me.botsko.prism.actionlibs.RecordingTask.save(RecordingTask.java:35)
  2014-07-11 16:02:51 [SEVERE]    at me.botsko.prism.actionlibs.RecordingTask.run(RecordingTask.java:332)
  2014-07-11 16:02:51 [SEVERE]    at org.bukkit.craftbukkit.v1_6_R3.scheduler.CraftTask.run(CraftTask.java:58)
  2014-07-11 16:02:51 [SEVERE]    at org.bukkit.craftbukkit.v1_6_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:53)
  2014-07-11 16:02:51 [SEVERE]    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
  2014-07-11 16:02:51 [SEVERE]    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
  2014-07-11 16:02:51 [SEVERE]    at java.lang.Thread.run(Thread.java:744)
  2014-07-11 16:02:51 [SEVERE] Caused by: java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.
  2014-07-11 16:02:51 [SEVERE]    at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2529)
  2014-07-11 16:02:51 [SEVERE]    at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2979)
  2014-07-11 16:02:51 [SEVERE]    ... 21 more
  2014-07-11 16:02:51 [INFO] [Prism]: Database connection error: Communications link failure
  </code></pre>
  
  <p>More Stacktraces, always the first exception from a fresh application session (complete restart) <a href="https://gist.github.com/Slind14/cd5a03ec289c30b1452e" rel="nofollow">https://gist.github.com/Slind14/cd5a03ec289c30b1452e</a></p>
  
  <p>As I couldn't find any solution, I'm wondering if you are aware of any change between 1310 and 1404 that could cause this to happen.</p>
  
  <pre><code>+-----------------------------+----------+
  | Variable_name               | Value    |
  +-----------------------------+----------+
  | connect_timeout             | 5        |
  | deadlock_timeout_long       | 50000000 |
  | deadlock_timeout_short      | 10000    |
  | delayed_insert_timeout      | 300      |
  | innodb_flush_log_at_timeout | 1        |
  | innodb_lock_wait_timeout    | 50       |
  | innodb_rollback_on_timeout  | OFF      |
  | interactive_timeout         | 28800    |
  | lock_wait_timeout           | 31536000 |
  | net_read_timeout            | 30       |
  | net_write_timeout           | 60       |
  | slave_net_timeout           | 3600     |
  | thread_pool_idle_timeout    | 60       |
  | wait_timeout                | 28800    |
  +-----------------------------+----------+
  </code></pre>
  
  <p>Update:</p>
  
  <p>when I keep the remote database open for a while I also get "MySQL server has gone away", again only on the 1404 servers.</p>
  
  <pre><code>ERROR 2006 (HY000): MySQL server has gone away
  No connection. Trying to reconnect...
  Connection id:    38189
  Current database: *** NONE ***
  </code></pre>