0
 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

My JDBC link is fully working.

  • 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

My especific questions are:

  • Is this error caused by network? because it looks like totally random.
  • Is this the propper mysql-connector for the mysql version or could this be the source of all errors?

Thank you

UrielUVD
  • 482
  • 1
  • 9
  • 27

1 Answers1

2

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.

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.

Community
  • 1
  • 1
jpkroehling
  • 13,881
  • 1
  • 37
  • 39
  • We are using Hibernate for pooling connections, but we left the default `pool_size=1`, Should we increase it?. Sould add that `autoReconnect=true` to the url property as you pointed? We actually use `jdbc:mysql://localhost:3306/mybase?zeroDateTimeBehavior=convertToNull` – UrielUVD Jun 08 '16 at 15:59
  • Hibernate doesn't pool connections by itself. Look at the link on "you should" on the main answer. If you are deploying your application into an application server, you should configure it accordingly. For instance, look at the `validation` options for Wildfly: https://github.com/wildfly/wildfly/blob/master/connector/src/test/resources/org/jboss/as/connector/subsystems/datasources/datasources-full.xml – jpkroehling Jun 08 '16 at 16:02
  • Will it help to the connection if I increase the `connect_timeout` var? Actually it is set to `30` and the `wait_timeout` and `interactive_timeout` to default. I read [here](http://stackoverflow.com/questions/6865538/solving-a-communications-link-failure-with-jdbc-and-mysql) that it may help, Do you have any advice on this? I suspect that the reason is the network because we provide this connection fro Web Services and a lot of clients are using it, and this problem turns out with only one of them – UrielUVD Jun 09 '16 at 16:37
  • Not necessarily. You can tweak and see if your application will behave better, but really, the appropriate solution is to tell the pool to only deliver good connections to your application. – jpkroehling Jun 09 '16 at 17:37
  • As you predicted, increasing `connection_timeout` didn´t solve it, at least at this point. I will run performance tests (Just massive requests, honestly) to inspect the behavior. I was assigned to solve this project issues and they told me it use hibernate but it is not, the .cnf is just there but there is no implementation, i will develope the entire persistance implementation. Thank you – UrielUVD Jun 11 '16 at 04:40