java.net.SocketException: Broken pipe

后端 未结 2 854
再見小時候
再見小時候 2021-02-14 20:25

I get this error or my jsp page every day:

java.net.SocketException

MESSAGE: Broken pipe

STACKTRACE:

java.net.SocketExc         


        
2条回答
  •  眼角桃花
    2021-02-14 20:55

    I get this error or my JSP page every day (...)

    I'm going to speculate a bit but if this happens every morning (i.e. after a night of inactivity), then it might be related to the fact that MySQL closes idle connections after 8 hours by default (the wait_timeout).

    If this is the case, either:

    • configure tomcat to test connections on borrow using a validationQuery in the datasource configuration:

      
        validationQuery
        select 1
      
      
    • increase MySQL's wait_timeout via my.cnf/my.ini, or by connecting with a command-line SQL client and entering SET GLOBAL wait_timeout=86400, or some other suitable number of seconds.

    I'm not aware of all the consequences of the second option and don't really recommend it, at least not without getting more feedback from MySQL experts.

提交回复
热议问题