Communications link failure, the last packet successfully received from the server was *** millisecon

Source: Internet
Author: User

In a recent test, it was found that MySQL could not be connected for a period of time, resulting in inconsistent database data and extremely depressing.

The following is the story of yiyunmen.

 

 

Use connector/J to connect to the MySQL database,ProgramAfter running for a long time, the following error is reported:

Communications link failure, the last packet successfully received from the server was *** millisecond ago. The last packet successfully sent to the server was *** millisecond ago.

The error will also prompt you to modify wait_timeout or use the autoreconnect attribute of ctor/J to avoid this error.

Later, I checked some information and found that there were quite a few people who encountered this problem. Most of them encountered this problem only when using the connection pool. Short connections should be difficult to see this problem. Cause:

The default "wait_timeout" of the MySQL server is 28800 seconds, that is, 8 hours. This means that if the idle time of a connection exceeds 8 hours, MySQL will automatically disconnect the connection, the connection pool considers the connection to be valid (because the connection is not verified). When the application applies to use the connection, the above error is reported.

1. according to the error message, you can use the autoreconnect attribute in the jdbc url. In the actual test, autoreconnect = true & failoverreadonly = false is used, but it does not work. Version 5.1 is used, it may be effective only for versions earlier than 4 As mentioned on the Internet.

2. No way. You can only modify the MySQL parameter. The maximum value of wait_timeout is 31536000, that is, 1 year. Add the following to my. CNF:

[Mysqld]

Wait_timeout = 31536000

Interactive_timeout = 31536000

The restart takes effect. You need to modify these two parameters at the same time.

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/cau99/archive/2009/12/11/4987760.aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.