CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2011
    Posts
    6

    Error! 'Mysql server has gone away' even though wait_timeout is 3600

    hi, i have a vb6 app that connects to a mysql database online. Everything (connection,save,search and query) works fine but if i leave the form idle for 2 minutes, i receive the error 'My sql server has gone away' .

    After surfing, i found out d cause of the error is the wait_timeout value on mysql being low. I checked the wait_timeout value on the mysql database and it is 3600 which means 1 hr. So this means, i shouldnt receive this error until and unless the software is idle for more than an hour. Right ?
    But i receive the error if the software remains idle for a minute or so.

    For now, i can trap the error and re-connect, but it is very slow and frustrating because every 2 mins i need to do it.

    FYI : I m using ado to connect and i have the mysql 3.51 drivers installed.

    Please advise. Thanks.

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Error! 'Mysql server has gone away' even though wait_timeout is 3600

    Do you know what kind of connection you are using?

    The Wait_Timeout applies only to TCP/IP and Unix sockets it does not apply to Named Pipes or shared memory connections.

    •wait_timeout
    Command-Line Format --wait_timeout=#
    Option-File Format wait_timeout
    Option Sets Variable Yes, wait_timeout
    Variable Name wait_timeout
    Variable Scope Global, Session
    Dynamic Variable Yes
    Permitted Values
    Type numeric
    Default 28800
    Range 1-31536000
    Permitted Values
    Type (windows) numeric
    Default 28800
    Range 1-2147483

    The number of seconds the server waits for activity on a noninteractive connection before closing it. This timeout applies only to TCP/IP and Unix socket file connections, not to connections made using named pipes, or shared memory.
    On thread startup, the session wait_timeout value is initialized from the global wait_timeout value or from the global interactive_timeout value, depending on the type of client (as defined by the CLIENT_INTERACTIVE connect option to mysql_real_connect()). See also interactive_timeout.
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    May 2011
    Posts
    6

    Re: Error! 'Mysql server has gone away' even though wait_timeout is 3600

    Hi, thanks for the reply. I m not sure what kind of connection it is. I use adodc control and this is the code i have on form load.
    Code:
    With ado
    .ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" & _  
                    "SERVER=" & strServerName & _  
                    ";DATABASE=" & strDatabaseName & ";" & _  
                    "USER=" & strUserName & _  
                    ";PASSWORD=" & strPassword & _  
                    ";OPTION=3;"
    This is the first time i m using mysql, so my knowledge is very limited. When i go to phpmyadmin on cpanel, it says 'local host via unix socket' and has the mysql version below it.

    I m using ado connection and i have a datagrid control on the same form. If the form is idle for sometime, the datagrid's update/delete functions also fail. I m thinking 'ado' has some sort of connection with this. Is there anything i m missing(probably some timeout value for the ado) ?

    please advise, sorry for my limited knowledge.

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Error! 'Mysql server has gone away' even though wait_timeout is 3600

    This is the place to look: http://www.connectionstrings.com/mysql
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured