通信链路故障 - 从服务器成功接收到的最后一个数据包是 [重复]
Posted
技术标签:
【中文标题】通信链路故障 - 从服务器成功接收到的最后一个数据包是 [重复]【英文标题】:Communications link failure - last packet successfully received from the server was [duplicate] 【发布时间】:2014-09-02 05:17:00 【问题描述】:我知道以前有人问过这个问题,并且有很多解决方案,但没有一个对我有用,而且在我的情况下有点不同。
我有一个带有数据库的服务器,它通过隧道连接到其他服务器。运行 ubuntu 1310 和 1204 的服务器没有任何问题。但是使用相同的设置、相同的配置、相同的应用程序,我在 1404 上遇到了这个问题。
服务器设置:
A - Ubuntu 1204 Server with MariaDB 10.0 Database
B - Ubuntu 1204 Server with MariaDB 5.5 Client -> tunneled via autossh 14c and works perfect
C - Ubuntu 1204 Server with MariaDB 5.5 Client -> tunneled via autossh 14c and works perfect
D - Ubuntu 1310 Server with MariaDB 5.5 Client -> tunneled via autossh 14c and works perfect
E - Ubuntu 1310 Server with MariaDB 5.5 Client -> tunneled via autossh 14c and works perfect
F - Ubuntu 1310 Server with MariaDB 5.5 Client -> 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) -> tunneled via autossh 14c DOES NOT WORK though same setup and app:
.
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
更多 Stacktraces,总是来自新应用程序会话的第一个异常(完全重启)https://gist.github.com/Slind14/cd5a03ec289c30b1452e
由于我找不到任何解决方案,我想知道您是否知道 1310 和 1404 之间的任何更改都可能导致这种情况发生。
+-----------------------------+----------+
| 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 |
+-----------------------------+----------+
更新:
当我将远程数据库保持打开一段时间时,我还会收到“MySQL 服务器已消失”,再次仅在 1404 服务器上。
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 38189
Current database: *** NONE ***
【问题讨论】:
可以用cmd访问mysql服务器并与之通信吗? 当然,例如,post 中的表在远程服务器上运行良好,应用程序也暂时运行良好。如果是我的应用程序,我可以检查连接是否有效,如果不创建新连接或启用自动重新连接,但这并不能解释为什么它只发生在 1404 上,并且对于我来说没有第三方应用程序的解决方案。 尝试去激活你的my.cnf中的查询缓存“query_cache_size=0”,重启mysql服务器再试一次。您也可以尝试像这样重置查询缓存:“重置查询缓存”。如果没有帮助,请提供有关查询、如何创建会话等的更多信息... 不起作用 :(您还想知道什么?连接是由第三方应用程序创建的,我在 1310 和 1204 服务器上进行了相同的设置,可以正常工作。配置没有区别或如何建立数据库连接。 请检查您的配置。 “wait_timeout”属性的值是多少。哦..我明白了.. 【参考方案1】:默认情况下,在交互式会话中 show variables 显示 interactive_timeout 而不是 wait_timeout
只需使用选项 -e 查看超时的实际值
http://blog.mozilla.org/it/2012/04/24/when-is-qwait_timeout-not-wait_timeout/
【讨论】:
以上是关于通信链路故障 - 从服务器成功接收到的最后一个数据包是 [重复]的主要内容,如果未能解决你的问题,请参考以下文章
DatabaseException CommunicationsException:通信链路故障
客户端通信层从 Advantage 数据库服务器接收到的数据比预期的要多