Re: Connector/J "Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost."
Posted by: Josh Jacobs
Date: July 06, 2009 10:45AM

I was seeing the same problem reported in my java application while using C3p0. I resolved the problem by removing this line from my my.cnf

#wait_timeout=30

I think the problem is the result of a mismatch of application connections properties and db configurations. I think that the database had a short wait_timeout than the application connection properties. In my case I had c3p0 set test connections every 60 seconds (<property name="hibernate.c3p0.idle_test_period">60</property>), while at the same time the db was expiring connections every 30 seconds. The error occurred because the database closes the connections while the application thinks they should still be guaranteed to be alive.

I will now try increasing the wait_timeout to a value of 90 to see if the problem arises again. That way I won't have to rely on a default in MySQL which could change.

I hope this helps others since this is a particularly excruciating bug to resolve!

Options: ReplyQuote


Subject
Written By
Posted
Re: Connector/J "Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost."
July 06, 2009 10:45AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.