# TCP and json versus json\_lines when sending multiple messages

**URL:** <https://discuss.elastic.co/t/tcp-and-json-versus-json-lines-when-sending-multiple-messages/46048>\
**Category:** Logstash\
**Created:** [April 1, 2016, 11:11am UTC](https://discuss.elastic.co/t/tcp-and-json-versus-json-lines-when-sending-multiple-messages/46048 "2016-04-01T11:11:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Benson\_Margulies](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benson_margulies/32/8825_2.png) [@Benson\_Margulies](https://discuss.elastic.co/u/Benson_Margulies)\
**Post date:** [April 1, 2016, 11:11am UTC](https://discuss.elastic.co/t/tcp-and-json-versus-json-lines-when-sending-multiple-messages/46048/1 "2016-04-01T11:11:45Z")

</div>

I have a java program which needs to deliver some specialized traffic to logstash, so using log4j or logback is not appropriate.

So, I set up logstash with a tcp socket and the json codec, and coded the program to connect a socket and send json.

If I push the json with nc, it shows up at logstash. When my code sends it, never.

I'm perplexed by json versus json\_lines. If I want to keep the connection open indefinitely and send a json object every so often, do I use json\_lines and add a newline, or just use json and expect logstash to notice the closing '}'?

---

<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:04am UTC](https://discuss.elastic.co/t/tcp-and-json-versus-json-lines-when-sending-multiple-messages/46048/2 "2017-07-06T05:04:21Z")

</div>

Closed on July 6, 2017, 5:04am UTC


