Communications link failure, the last packet successfully received to the server was 18,903 Millis

Source: Internet
Author: User
Tags aop

The

Today's development environment has the following error with the connection datagram, and the error message is as follows:

The last packet successfully received from the server is 18,903 milliseconds ago.  the last packet sent successful 
Ly to the server is 18,901 milliseconds ago.; Nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:Communications link failure the last Packe  T successfully received from the server is 18,903 milliseconds ago.  the last packet sent successfully to the server
was 18,901 milliseconds ago.   at Org.springframework.jdbc.support.SQLExceptionSubclassTranslator.doTranslate ( sqlexceptionsubclasstranslator.java:98) ~[spring-jdbc-4.2.7.release.jar:4.2.7.release]   at Org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate ( abstractfallbacksqlexceptiontranslator.java:73) ~[spring-jdbc-4.2.7.release.jar:4.2.7.release]   at Org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate ( abstractfallbacksqlexceptiontranslator.java:81) ~[spring-jdbc-4.2.7.release.jar:4.2.7.release]   atOrg.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible (mybatisexceptiontranslator.java:75) ~[MYBATIS-SPRING-1.3.0.JAR:1.3.0]   at Org.mybatis.spring.sqlsessiontemplate$sqlsessioninterceptor.invoke ( sqlsessiontemplate.java:447) ~[mybatis-spring-1.3.0.jar:1.3.0]   at com.sun.proxy. $Proxy 97.selectList (Unknown Source) ~[na:na]   at Org.mybatis.spring.SqlSessionTemplate.selectList (sqlsessiontemplate.java:231) ~[ MYBATIS-SPRING-1.3.0.JAR:1.3.0]   at Org.apache.ibatis.binding.MapperMethod.executeForMany (Mappermethod.java : 128) ~[mybatis-3.4.0.jar:3.4.0]   at Org.apache.ibatis.binding.MapperMethod.execute (mappermethod.java:68) ~[ MYBATIS-3.4.0.JAR:3.4.0]   at Org.apache.ibatis.binding.MapperProxy.invoke (mapperproxy.java:53) ~[ MYBATIS-3.4.0.JAR:3.4.0]   at com.sun.proxy. $Proxy 117.listOfCirculationOrderBy (Unknown Source) ~[na:na]   At Com.cloud.saas.official.service.impl.CirculationServiceImpl.listOfCirculationOrderBy (Circulationserviceimpl. java:98) ~[classes/:na]   at com.cloud.saas.official.service.impl.circulationserviceimpl$$ Fastclassbyspringcglib$$7c31abe8.invoke (<generated>) ~[classes/:na]   at Org.springframework.cglib.proxy.MethodProxy.invoke (methodproxy.java:204) ~[spring-core-4.2.7.release.jar:4.2.7. Release]   at Org.springframework.aop.framework.cglibaopproxy$cglibmethodinvocation.invokejoinpoint ( cglibaopproxy.java:720) ~[spring-aop-4.2.7.release.jar:4.2.7.release]   at Org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (reflectivemethodinvocation.java:157) ~[ Spring-aop-4.2.7.release.jar:4.2.7.release]   at Org.springframework.transaction.interceptor.transactioninterceptor$1.proceedwithinvocation ( transactioninterceptor.java:99) ~[spring-tx-4.2.7.release.jar:4.2.7.release]   at Org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction ( transactionaspectsupport.java:281) ~[spring-tx-4.2.7.release.jar:4.2.7.release]   at ORg.springframework.transaction.interceptor.TransactionInterceptor.invoke (transactioninterceptor.java:96) ~[ Spring-tx-4.2.7.release.jar:4.2.7.release]   at Org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (reflectivemethodinvocation.java:179) ~[ Spring-aop-4.2.7.release.jar:4.2.7.release]   at org.springframework.aop.framework.cglibaopproxy$ Dynamicadvisedinterceptor.intercept (cglibaopproxy.java:655) ~[spring-aop-4.2.7.release.jar:4.2.7.release]   At com.cloud.saas.official.service.impl.circulationserviceimpl$ $EnhancerBySpringCGLIB $$ A6c1c39a.listofcirculationorderby (<generated>) ~[classes/:na]   at Com.cloud.saas.official.controller.CirculationController.listOfCirculation (circulationcontroller.java:79) ~[ Classes/:na]

There is a problem or Baidu, Google inquiries, this error is more common, the reason for this error:

MySQL server default "Wait_timeout" is 28,800 seconds or 8 hours, meaning that if a connection is idle for more than 8 hours, MySQL will automatically disconnect the connection, and the connection pool is considered to be valid (because the connection is not validated), When an application request uses the connection, the error is caused above.
To modify the MySQL parameter, the wait_timeout maximum is 31536000 that 1 years, add in MY.CNF:

[Mysqld]
wait_timeout=31536000
interactive_timeout=31536000

The reboot takes effect, and both parameters need to be modified at the same time.

I am here to use the Docker from the mysql5.7, so you can directly use the following command to add the above parameters:

Docker exec mysql bash-c "echo ' wait_timeout=31536000 ' >>/etc/mysql/mysql.conf.d/mysqld.cnf"
Docker exec MySQL bash-c "Echo ' interactive_timeout=31536000 ' >>/etc/mysql/mysql.conf.d/mysqld.cnf"

Docker restart Mysql



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.