Bug #56953 2013 error at 'waiting for initial communication packet, system error: 61
Submitted: 22 Sep 2010 21:19 Modified: 13 Oct 2010 20:19
Reporter: Plou Francois Email Updates:
Status: Closed Impact on me:
Category:MySQL Server Severity:S2 (Serious)
Version:5.1.43-powerpc-64bit OS:IBM AIX (5.3)
Assigned to: CPU Architecture:Any
Tags: 2013, communication packet, system error 61

[22 Sep 2010 21:19] Plou Francois
(2013 Lost connection to MySQL server at 'waiting for initial communication packet', system error: 61)

We get this error in production environment from C program that tries to initiate a connection to the database.
We wrote a test program that continuously (every 7 seconds) tries to connect to the database with the following API :

  unsigned int tmax = 5;	// 5 seconds


    mysql_options (SGBD, MYSQL_OPT_CONNECT_TIMEOUT, (char*)&tmax);

    time_t start = time (NULL);
    int LOC_good = (mysql_real_connect(SGBD, host, user, pass, base, port, (char*)0, 0U) != (MYSQL*)0);
    time_t done = time (NULL);

    if(done-start > 1)
        printf("Connection lente (%d secondes) a %s\n",done-start,hour());

    if(!LOC_good) {
      printf("erreur connexion (%d %s) a %s", mysql_errno(SGBD), mysql_error(SGBD), hour());


    if(pause) sleep(pause);

We connect to the database to localhost address and to a dedicated port different than the standard 3306.
So the connection takes more than 5 seconds to complete. As our code does not yet manage a pooled connection, this slow connection process is a problem in our workflow.

Do you have any clue about that ?


How to repeat:
We discovered that the 2013 error occurs when a slow query (30 to 60 seconds) is in progress during the mysql_real_connect execution.
[23 Sep 2010 8:08] Susanne Ebrecht
How long is the connection needing when you use plane CLI?
[23 Sep 2010 8:59] Susanne Ebrecht
Yes, I meant the MySQL Command Line Client.
[23 Sep 2010 10:58] Plou Francois
Yes I dit the test on a qualification environment (same OS, same mySQL, same SGBD).

When a huge select request is in progress (50 seconds to process), the C program detects a connection time of 6 seconds. In the same time, a simple loop with a shell program calling mysql client detects the same average time.

The shell test program is the following :


while true
        time mysql -u root <database> <<!
        sleep 2

One output sample :

réel    0m6,90s
utilisateur     0m0,01s
sys     0m0,00s

[25 Sep 2010 7:27] Sveta Smirnova
Thank you for the feedback.

This is most likely not a bug, but something wrong in your environment. In C program you connecting using TCP connection, please try connect via socket also. Check with current version of MySQL 5.1.50 too.
[25 Sep 2010 7:46] Plou Francois

In this particular environnement, the mySQL database is hosted on same server as our application. But usually this is not the case, so the C program has to connect via TCP socket.

Anyway, I will do the test with the socket and with the 5.1.50 release.

I will let you know about results.

[13 Oct 2010 20:19] Plou Francois
We did not install the latest release.

Instead we reduced the number of open connection to the database (via C3P0 pool parameters) then set the thread_cache_size to 200.
The problem is solved.