# Communications link failure consistently after one hour with MySQL

**URL:** <https://discuss.elastic.co/t/communications-link-failure-consistently-after-one-hour-with-mysql/281031>\
**Category:** Logstash\
**Created:** [August 11, 2021, 10:16am UTC](https://discuss.elastic.co/t/communications-link-failure-consistently-after-one-hour-with-mysql/281031 "2021-08-11T10:16:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Justin\_Morgan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/justin_morgan/32/77578_2.png) [@Justin\_Morgan](https://discuss.elastic.co/u/Justin_Morgan)\
**Post date:** [August 11, 2021, 10:16am UTC](https://discuss.elastic.co/t/communications-link-failure-consistently-after-one-hour-with-mysql/281031/1 "2021-08-11T10:16:45Z")

</div>

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.

```auto
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

```

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [August 11, 2021, 4:25pm UTC](https://discuss.elastic.co/t/communications-link-failure-consistently-after-one-hour-with-mysql/281031/2 "2021-08-11T16:25:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 8, 2021, 4:26pm UTC](https://discuss.elastic.co/t/communications-link-failure-consistently-after-one-hour-with-mysql/281031/3 "2021-09-08T16:26:42Z")

</div>

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