RE: com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:

"Robert Stewart" <[email protected]> Fri, 25 May 2007 17:56:37 -0700
Newsgroups gmane.comp.db.mysql.java
Message-ID <[email protected]>
If you search the forums you can find a lot of other posts on this issue. The change is that the server kills connections that are idle for longer than wait_timeout. When your client app tries to use a connection that has been killed, the error below occurs when the client tries to read from the socket.

The new behavior is actually triggered by a change to the driver. I believe that the new behavior appeared in connector 3.0.8.

Here is a response I sent out before on how I worked around this change.

********
We set the wait_timeout on the server to be a very large number and the
idle timeout for our connection pool to be fairly small. For what we are
doing, the time required to create a new connection is not very
significant, so we usually have the idle timeout for connections in the
pool set to just a few minutes.

Applications using our connection pool can specify an optional
configuration property that the pool manager will use to validate the
connection before it is returned to the application. "SELECT 1" seems to
be succinct, safe, and performant. If the query fails, the connection is
removed from the pool and another one is tried. If the pool is empty, of
course, a new connection is created. 
********

Robert Stewart
Voxify

-----Original Message-----
From: Andreas Andersson [mailto:[email protected]] 
Sent: Friday, May 25, 2007 2:58 PM
To: [email protected]
Subject: Re: com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:

Christopher G. Stach II wrote:
> Andreas Andersson wrote:
>   
>> Hi!
>>
>> I'm running mysql 5.0.37 with mysql-connector-java-5.0.6. We just moved
>> from mysql 4.0.something and now we notice this annoying error.
>>
>> (full stacktrace)
>>
>> com.mysql.jdbc.CommunicationsException: Communications link failure due
>> to underlying exception:
>>
>> ** BEGIN NESTED EXCEPTION **
>>
>> com.mysql.jdbc.CommunicationsException
>> MESSAGE: Communications link failure due to underlying exception:
>>
>> ** BEGIN NESTED EXCEPTION **
>>
>> java.io.EOFException
>>
>> STACKTRACE:
>>
>> java.io.EOFException
>>         at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1956)
>>         at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2368)
>>         at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2867)
>>         at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:870)
>>         at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3333)
>>         at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1232)
>>         at com.mysql.jdbc.Connection.createNewIO(Connection.java:2749)
>>         at com.mysql.jdbc.Connection.<init>(Connection.java:1553)
>>         at
>> com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
>>         at java.sql.DriverManager.getConnection(DriverManager.java:512)
>>         at java.sql.DriverManager.getConnection(DriverManager.java:171)
>>  
>> This all happens on new connections created after between 50 and 90
>> minutes uptime on my tomcat server. Several connections are in use (and
>> being reused until they are dropped by the server) during that time.
>>
>> I get nothing in the error log at all.
>>
>> I'll be thankful for any input on this. Thanks.
>>     
>
> Connection timeout and close on the server side?  Check wait_timeout?
>
>   
wait_timeout is 600, the same as it was on our old mysql 4 (with the old
connector 3.0.5). Could this have changed in some way?
Could I in some way have more verbose logging from mysql and log what's
happening at the serverside when I get these messages on the client side?

thanks

-- 
Andreas Andersson
Senior Developer

Travelstart <http://www.travelstart.se>

Travelstart Nordic AB
Davidshallsgatan 14
211 45 Malmö

www.travelstart.se <http://www.travelstart.se>
www.travelstart.dk <http://www.travelstart.dk>
	  	Tel +46 (0)40-690 38 83
Mob +46 (0)70-757 23 73
Fax +46 (0)40-611 17 78

www.travelstart.no <http://www.travelstart.no>
www.travelstart.co.za <http://www.travelstart.co.za>


-- 
MySQL Java Mailing List
For list archives: http://lists.mysql.com/java
To unsubscribe:    http://lists.mysql.com/[email protected]


-- 
MySQL Java Mailing List
For list archives: http://lists.mysql.com/java
To unsubscribe:    http://lists.mysql.com/[email protected]