# Strange hanging/buffering behavior with tcp plugin

**URL:** <https://discuss.elastic.co/t/strange-hanging-buffering-behavior-with-tcp-plugin/33042>\
**Category:** Logstash\
**Created:** [October 27, 2015, 4:47am UTC](https://discuss.elastic.co/t/strange-hanging-buffering-behavior-with-tcp-plugin/33042 "2015-10-27T04:47:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![treehouse](https://avatars.discourse-cdn.com/v4/letter/t/e9a140/32.png) [@treehouse](https://discuss.elastic.co/u/treehouse)\
**Post date:** [October 27, 2015, 4:47am UTC](https://discuss.elastic.co/t/strange-hanging-buffering-behavior-with-tcp-plugin/33042/1 "2015-10-27T04:47:02Z")

</div>

I am feeding one logstash output into the input of another logstash instance. I am using the tcp output plugin (in logstash A) for data output, and tcp input plugin for data input (logstash B). I'm seeing some strange behavior here in that no matter how many "logs" I send through logstash A, none show up in logstash B until I quit logstash A. And what shows up in Logstash B is _only the very first log I sent through logstash A_. So I know that logstash A definitely knows where logstash B lives and can pipe data to it. But something seems to be hanging and/or buffering the output from logstash B.  
Below are my configs:

_output_ config:

```
input {
	stdin {}
}

filter {}

output {
	stdout { codec => rubydebug }
	tcp {
		mode => "client"
		host => "localhost"
		port => 5043
	}
}

```

_input_ config:

```
input {
	tcp {
		mode => "server"
		port => 5043
	}
}

filter {
	json {
		source => "message"
	}
	json {
		source => "message"
	}

}

output{
	stdout { codec => rubydebug }
}

```

I have asked a similar question here -- [Logstash tcp input/output](https://discuss.elastic.co/t/logstash-tcp-input-output/32901) -- but no solutions thus far. Just didn't want the topic to slowly die, because I'd like to figure out a solution asap. Maybe I should submit a defect ticket on logstash project on github?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [October 27, 2015, 7:01am UTC](https://discuss.elastic.co/t/strange-hanging-buffering-behavior-with-tcp-plugin/33042/2 "2015-10-27T07:01:25Z")

</div>

It's a codec mismatch problem. The tcp output defaults to emitting JSON messages on a single line (which isn't consistent with the documentation that states that each event will be followed by a newline) while the tcp input waits for a newline before emitting anything. Changing to the json\_lines codec on both the input and the output fixes the problem (and you won't need any json filters to parse the JSON payload).

---

<div class="post-metadata">

**Author:** ![treehouse](https://avatars.discourse-cdn.com/v4/letter/t/e9a140/32.png) [@treehouse](https://discuss.elastic.co/u/treehouse)\
**Post date:** [November 3, 2015, 10:53pm UTC](https://discuss.elastic.co/t/strange-hanging-buffering-behavior-with-tcp-plugin/33042/3 "2015-11-03T22:53:46Z")

</div>

I can't use the json\_lines codec for some reason..

> [@Json codec crashing logstash](https://discuss.elastic.co/t/json-codec-crashing-logstash/33680):
>
> I have courier input feeding the pipeline. When i try using the tcp output using codec =\> json or codec =\> json\_lines, logstash crashes and spits this error -- LogStash::Json::GeneratorError: Failed to load class 'org.jruby.RubyObject$Access4JacksonDeserializerc66a1575': com.fasterxml.jackson.module.afterburner.ser.BeanPropertyAccessor jruby\_dump at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.0.0-java/lib/logstash/json.rb:53 to\_json at /opt/logstash/vendor/bundle/jru…

---

<div class="post-metadata">

**Author:** ![treehouse](https://avatars.discourse-cdn.com/v4/letter/t/e9a140/32.png) [@treehouse](https://discuss.elastic.co/u/treehouse)\
**Post date:** [November 4, 2015, 12:29am UTC](https://discuss.elastic.co/t/strange-hanging-buffering-behavior-with-tcp-plugin/33042/4 "2015-11-04T00:29:47Z")

</div>

It must be to do with using the courier input to receive the event.. because I don't get this error when i just use the stdin input and type my own event eg, "{}"

---

<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:** [July 6, 2017, 5:24am UTC](https://discuss.elastic.co/t/strange-hanging-buffering-behavior-with-tcp-plugin/33042/5 "2017-07-06T05:24:12Z")

</div>


