Communications link failure consistently after one hour with MySQL

I am using logstash with JDBC to import data from MySQL into Elasticsearch. This has worked before but now it is consistently failing after 1 hour with this exception:

`Exception when executing JDBC query {:exception=>"Java::ComMysqlCjJdbcExceptions::CommunicationsException: Communications link failure\n\nThe last packet successfully received from the server was 3,600,219 milliseconds ago. The last packet sent successfully to the server was 3,600,221 milliseconds ago`

The wait_timeout on the server is 28800 and I added it as a session variable too. I tried increasing the connect_timeout variable from 10 to 30 as well.

Here is an extract from the logstash config file. I added the jdbc_validation_timeout to try to fix this but it did not help.

jdbc_driver_library => "/opt/bitnami/logstash/logstash-core/lib/jars/mysql-connector-java.jar"
        jdbc_driver_class => "com.mysql.cj.jdbc.Driver"
        jdbc_connection_string => "jdbc:mysql://db:3306/dbname?zeroDateTimeBehavior=convertToNull&useCursorFetch=true&autoReconnect=true&sessionVariables=group_concat_max_len=150000,sort_buffer_size=524288,wait_timeout=28800,interactive_timeout=28800"
        jdbc_paging_enabled => true
        jdbc_page_size => 1000000
        jdbc_validate_connection => true
        jdbc_validation_timeout => 300
        connection_retry_attempts => 10
        connection_retry_attempts_wait_time => 30

Clearly something is closing the connection after one hour. Is there a firewall or NAT device between logstash and the DB?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.