Re: MySql connection timeout

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Tue Mar 31 2009 - 07:43:46 EDT

  • Next message: Dave Merrin: "Re: MySql connection timeout"

    The default timeout is not 8 hours, but something much shorter (like 5
    minutes). Both client and server side settings effect that. Cayenne
    does NOT do anything to reconnect by itself, so usually you'd see it
    pretty quickly. It does depend on your pool configuration though. E.g.
    if you set it to reopen a connection every time, obviously no timeouts
    will occur. So no idea why you can't reproduce it, but DataSource
    configuration is the place to start with.

    The link that Andrey provided is a bit dated. To autoreconnect under
    MySQL you need a bit more effort:

    1. URL parameters: connectTimeout=0&autoReconnect=true
    2. Validation query. Believe it or not, #1 above is not enough to
    prevent errors. You also need a validation query, which can be set if
    you are using a DBCP connection pool. Here is a link explaining how to
    set it on Tomcat:

    http://confluence.atlassian.com/display/JIRA/Surviving+Connection+Closures

    Andrus

    On Mar 31, 2009, at 2:30 PM, Andrey Razumovsky wrote:

    > This is a known problem, have a look at
    > http://cwiki.apache.org/CAY/reconnect.html
    >
    > 2009/3/31 Dave Merrin <dmerri..pasystems.co.uk>
    >
    >> Hi,
    >>
    >> I've read about and understand that my application is having its
    >> connection
    >> timed out after 8 hours of inactivity using MySql. I've set the
    >> timeout to
    >> be 120 seconds so I can try and reproduce the error without waiting
    >> for 8
    >> hours. Unfortunately I'm never seeing the problem. I connect, make
    >> some
    >> queries, sleep for 3 minutes, then make some more queries. I never
    >> get the
    >> timeout exception.
    >>
    >> Is Cayenne doing something behind the scenes?
    >>
    >> Cheers,
    >>
    >> Dave
    >>
    >>



    This archive was generated by hypermail 2.0.0 : Tue Mar 31 2009 - 07:48:45 EDT