间歇性JDBC管道中断和链接失败 [英] Intermittent JDBC Broken Pipe and Link Failure

查看:105
本文介绍了间歇性JDBC管道中断和链接失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 Excepcion:com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
 ...
 Caused by: java.net.SocketException: Broken pipe

我已经阅读了很多与此问题类似的问题. 所以,在宣布这个问题不值得"之前,让我先澄清一些事情

I have already read a lot of question similar to this one. So, before declaring this question 'unworthy' let me clarify some things

我的JDBC链接完全正常工作.

My JDBC link is fully working.

  • 没有身份验证问题
  • SQL已启动并正在运行
  • max_connections(永远是300)永远不会达到
  • 并发线程连接始终在5到9之间
  • 我正在使用MySQL 5.0.95(是的,我知道,我无法控制服务器资源)
  • 和Mysql-connector-java 5.1.5
  • 已基于Percona Toolkit配置了mysql性能变量
  • No problem of authentication
  • Sql is up and running
  • The max_connections, wich is 300, is never reached
  • The concurrent thread connections are always between 5 and 9
  • Im using MySQL 5.0.95 (Yes... I´know,I have no control on the server resources)
  • And Mysql-connector-java 5.1.5
  • The mysql performance vars have been configured based on Percona Toolkit

我的具体问题是:

  • 此错误是由网络引起的吗?因为它看起来完全是随机的.
  • 这是适用于mysql版本的合适的mysql-connector还是所有错误的来源?

谢谢

推荐答案

Broken pipe消息表示另一端关闭了连接,这可能是由于接收到的数据包顺序错误或客户端与服务器之间的状态不正确不同步或类似的东西.也许您的应用程序和服务器之间存在防火墙,可以杀死持久连接?也许一段时间以来,管道(连接)上什么都没有发生,而服务器关闭了它?无论如何,如果您使用连接池机制(您应该!),则应该可以委派处理这样的情况.

A Broken pipe message means that the other end closed the connection, possibly because of a wrong order of packets received, or because the state between client and server isn't synchronized or something like that. Perhaps there's a firewall between your application and the server that kills persistent connections? Or perhaps there was nothing going on the pipe (connection) for some time, and the server closed it? In any case, if you are using a connection pooling mechanism (you should!), it should be possible to delegate the handling of such situations to it.

或者,如果您打算始终使用MySQL,则可以尝试将failOverReadOnly=false&maxReconnects=10&autoReconnect=true添加到您的连接字符串中.这是特定于MySQL JDBC驱动程序的,因此,我真的建议您配置连接池机制,以在将连接交付给应用程序之前测试连接.

Or, if you intend to always use MySQL, you can try to add failOverReadOnly=false&maxReconnects=10&autoReconnect=true to your connection string. This is specific to the MySQL JDBC driver, so, I'd really advise you to configure your connection pooling mechanism to test the connections before delivering them to your application.

这篇关于间歇性JDBC管道中断和链接失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆