# Logstash TCP Output Plugin Reconnect Interval Issue

**URL:** <https://discuss.elastic.co/t/logstash-tcp-output-plugin-reconnect-interval-issue/251788>\
**Category:** Logstash\
**Created:** [October 12, 2020, 3:22pm UTC](https://discuss.elastic.co/t/logstash-tcp-output-plugin-reconnect-interval-issue/251788 "2020-10-12T15:22:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paddy\_F](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paddy_f/32/48475_2.png) [@Paddy\_F](https://discuss.elastic.co/u/Paddy_F)\
**Post date:** [October 12, 2020, 3:22pm UTC](https://discuss.elastic.co/t/logstash-tcp-output-plugin-reconnect-interval-issue/251788/1 "2020-10-12T15:22:39Z")

</div>

Hi,

I'm having a problem with the [logstash tcp output plugin](https://www.elastic.co/guide/en/logstash/current/plugins-outputs-tcp.html), the reconnect\_interval does not seem to have an affect on the plugin's actual reconnect attempts? I may be misunderstanding what the field is used for exactly but no matter what I set it to I see the following pattern of reconnect attempts if the TCP server I'm trying to connect to is down:

```auto
Failed (Connection refused - connect(2) for "10.0.20.158" port 13370). Sleeping for 0.02
Failed (Connection refused - connect(2) for "10.0.20.158" port 13370). Sleeping for 0.04
Failed (Connection refused - connect(2) for "10.0.20.158" port 13370). Sleeping for 0.08
Failed (Connection refused - connect(2) for "10.0.20.158" port 13370). Sleeping for 0.16
Failed (Connection refused - connect(2) for "10.0.20.158" port 13370). Sleeping for 0.32
Failed (Connection refused - connect(2) for "10.0.20.158" port 13370). Sleeping for 0.64
Failed (Connection refused - connect(2) for "10.0.20.158" port 13370). Sleeping for 1.28
Failed (Connection refused - connect(2) for "10.0.20.158" port 13370). Sleeping for 2.0
Failed (Connection refused - connect(2) for "10.0.20.158" port 13370). Sleeping for 2.0
Failed (Connection refused - connect(2) for "10.0.20.158" port 13370). Sleeping for 2.0

```

Here is an example of the output plugin's config:

```auto
 output {
      stdout { codec => rubydebug }
      tcp {
        host => "${TCP_OUTPUT_HOST}"
        port => "${TCP_OUTPUT_PORT}"
        reconnect_interval => "15"
        mode => "client"
        codec => "plain
      }
  }

```

---

<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:** [October 12, 2020, 3:59pm UTC](https://discuss.elastic.co/t/logstash-tcp-output-plugin-reconnect-interval-issue/251788/2 "2020-10-12T15:59:34Z")

</div>

That is confusing! What you are seeing is the [stud](https://github.com/jordansissel/ruby-stud/blob/master/lib/stud/try.rb) retry handling in the [connect](https://github.com/logstash-plugins/logstash-output-tcp/blob/f901607962806420e0e09f9a78be8cded1fb2641/lib/logstash/outputs/tcp.rb#L176) method.

The sleep reconnect\_interval only happens once connect throws an exception. It will sleep for the reconnect\_interval then go back into connect and do the retries with exponential backoff again.

I would expect the backoff to go down to 0.02 again, not stay at 2.0 🤔

---

<div class="post-metadata">

**Author:** ![Paddy\_F](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paddy_f/32/48475_2.png) [@Paddy\_F](https://discuss.elastic.co/u/Paddy_F)\
**Post date:** [October 13, 2020, 8:22am UTC](https://discuss.elastic.co/t/logstash-tcp-output-plugin-reconnect-interval-issue/251788/3 "2020-10-13T08:22:06Z")

</div>

Thanks for your reply! 👍 Well spotted. That's interesting, I've left it running for long periods and it seems to stay on 2.0s indefinitely, and doesn't seem to throw an exception at all. Not sure if that's expected/unexpected behaviour here

---

<div class="post-metadata">

**Author:** ![Paddy\_F](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paddy_f/32/48475_2.png) [@Paddy\_F](https://discuss.elastic.co/u/Paddy_F)\
**Post date:** [October 15, 2020, 8:52am UTC](https://discuss.elastic.co/t/logstash-tcp-output-plugin-reconnect-interval-issue/251788/4 "2020-10-15T08:52:36Z")

</div>

Sorry to be harping on about this but I'm just wondering if this would be considered a bug, or a documentation error at least? The docs on the plugin implies that if a connection fails, the plugin will retry based on that field but in my case here, which I'd imagine is somewhat common, the reconnect\_interval is seemingly never taken into account?

---

<div class="post-metadata">

**Author:** ![Paddy\_F](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paddy_f/32/48475_2.png) [@Paddy\_F](https://discuss.elastic.co/u/Paddy_F)\
**Post date:** [October 15, 2020, 1:18pm UTC](https://discuss.elastic.co/t/logstash-tcp-output-plugin-reconnect-interval-issue/251788/5 "2020-10-15T13:18:46Z")

</div>

Looks like there is an open issue in the TCP Output Plugin repo on this already:

> <https://github.com/logstash-plugins/logstash-output-tcp/issues/12>
>
> For reconnects Stud::try is used (https://github.com/logstash-plugins/logstash-output-tcp/blob/master/lib/logstash/outputs/tcp.rb#L123), which has two side effects:
> Stud::try does not respect the reconnect\_interval configured for the plugin but...

---

<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:** [November 12, 2020, 1:18pm UTC](https://discuss.elastic.co/t/logstash-tcp-output-plugin-reconnect-interval-issue/251788/6 "2020-11-12T13:18:51Z")

</div>

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