# No output from TCP input

**URL:** <https://discuss.elastic.co/t/no-output-from-tcp-input/97753>\
**Category:** Logstash\
**Created:** [August 21, 2017, 11:12am UTC](https://discuss.elastic.co/t/no-output-from-tcp-input/97753 "2017-08-21T11:12:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![capaneus](https://avatars.discourse-cdn.com/v4/letter/c/41988e/32.png) [@capaneus](https://discuss.elastic.co/u/capaneus)\
**Post date:** [August 21, 2017, 11:12am UTC](https://discuss.elastic.co/t/no-output-from-tcp-input/97753/1 "2017-08-21T11:12:55Z")

</div>

Hi All,  
I'm trying logstash with python TCP input, I followed some sample code here:

> <https://gist.github.com/jgoodall/6323951>
>
> There are more than three files. show original

Adapted a bit the code, but I'm sending the exact same message through tcp.  
From python output:  
(MainThread) 2017-08-21 12:07:35,688 INFO b'{"@message": "Python test message", "@tags": ["python", "test"]}'

here is my logstash pipeline config file:  
input {  
tcp {  
port =\> "9563"  
host =\> "127.0.0.1"  
codec =\> "json\_lines"  
}

```
	beats {
		port => "5043"
		}
}
output {
	stdout { codec => rubydebug}
	elasticsearch {
		hosts => ["localhost:9200"]
		}
	file {
		path => "E:\log\output.log"
	}
}

```

I turned on logstash logging into debug, and found out this log every time I execute the code:  
[2017-08-21T12:07:35,691][DEBUG][logstash.inputs.tcp] Accepted connection {:client=\>"127.0.0.1:58256", :server=\>"127.0.0.1:9563"}  
[2017-08-21T12:07:35,694][DEBUG][logstash.codecs.jsonlines] config LogStash::Codecs::JSONLines/@id = "json\_lines\_4e6cdf95-0891-4c7f-90a1-c30fb1804c45"  
[2017-08-21T12:07:35,694][DEBUG][logstash.codecs.jsonlines] config LogStash::Codecs::JSONLines/@enable\_metric = true  
[2017-08-21T12:07:35,695][DEBUG][logstash.codecs.jsonlines] config LogStash::Codecs::JSONLines/@charset = "UTF-8"  
[2017-08-21T12:07:35,695][DEBUG][logstash.codecs.jsonlines] config LogStash::Codecs::JSONLines/@delimiter = "\n"  
`[2017-08-21T12:07:35,697][DEBUG][logstash.inputs.tcp] Connection closed {:client=\>"127.0.0.1:58256"}

But after that, nothing happened, there is no stdout output, no log file generated, neither does any elasticsearch record created.

Would you pls help me on this?

---

<div class="post-metadata">

**Author:** ![capaneus](https://avatars.discourse-cdn.com/v4/letter/c/41988e/32.png) [@capaneus](https://discuss.elastic.co/u/capaneus)\
**Post date:** [August 22, 2017, 12:11am UTC](https://discuss.elastic.co/t/no-output-from-tcp-input/97753/2 "2017-08-22T00:11:33Z")

</div>

After hours of trying, kind of solved issue, I tried with http input, using request lib in python , now Logstash can receive all the data properly and log them into the file properly.  
For other new user as reference:

Here is the python code:  
def \_\_sendContentHTTP(self, content):  
payload = {  
'@message': content,  
'@tags': ['your tag']  
}  
headers = {  
'Content-Type': 'application/json'  
}  
r = requests.post('[http://yourserver](http://yourserver):yourport', data=json.dumps(payload), headers=headers)

```
Logstash config:
    input {
    	http {
    		port => 9654
    	}
    }
    filter {
    	json {
    		source => "message"
    	}
	
	split {
		field => "@message"
	}
}
output {
	stdout { }
	file { 
		path => "your path\your filename"
		codec => json
	}
}
```

---

<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:** [August 23, 2017, 8:54pm UTC](https://discuss.elastic.co/t/no-output-from-tcp-input/97753/3 "2017-08-23T20:54:12Z")

</div>

> But after that, nothing happened, there is no stdout output, no log file generated, neither does any elasticsearch record created.

Did you end each message with a newline? Judging by the JavaScript code you posted I'd say no.

---

<div class="post-metadata">

**Author:** ![capaneus](https://avatars.discourse-cdn.com/v4/letter/c/41988e/32.png) [@capaneus](https://discuss.elastic.co/u/capaneus)\
**Post date:** [August 24, 2017, 3:53pm UTC](https://discuss.elastic.co/t/no-output-from-tcp-input/97753/4 "2017-08-24T15:53:34Z")

</div>

Thanks  
Probably that's the issue. The message I sent was about an object array with about 100 element in there, after json dumps from python, it probably became 1 line.  
I might try a bit more and see

---

<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 21, 2017, 3:53pm UTC](https://discuss.elastic.co/t/no-output-from-tcp-input/97753/5 "2017-09-21T15:53:50Z")

</div>

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