# Input tcp error

**URL:** <https://discuss.elastic.co/t/input-tcp-error/100336>\
**Category:** Logstash\
**Created:** [September 13, 2017, 10:26am UTC](https://discuss.elastic.co/t/input-tcp-error/100336 "2017-09-13T10:26:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![xiaopeng\_zhang](https://avatars.discourse-cdn.com/v4/letter/x/71e660/32.png) [@xiaopeng\_zhang](https://discuss.elastic.co/u/xiaopeng_zhang)\
**Post date:** [September 13, 2017, 10:26am UTC](https://discuss.elastic.co/t/input-tcp-error/100336/1 "2017-09-13T10:26:24Z")

</div>

i use the logback to send the log by tcp port 80,  
and i use the logstash-logback-encoder plugin.  
pom.xml:  
`<modelVersion>4.0.0</modelVersion>`

```
  <groupId>edu.zxp</groupId>
  <artifactId>log4jlearn</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>log4jlearn</name>
  <url>http://maven.apache.org</url>
  <properties>
   <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <ch.qos.logback.version>1.2.3</ch.qos.logback.version>
  </properties>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
            <dependency>
                <groupId>ch.qos.logback</groupId>
                <artifactId>logback-core</artifactId>
                <version>${ch.qos.logback.version}</version>
            </dependency>
            <dependency>
                <groupId>ch.qos.logback</groupId>
                <artifactId>logback-classic</artifactId>
                <version>${ch.qos.logback.version}</version>
            </dependency>
            <dependency>
                <groupId>ch.qos.logback</groupId>
                <artifactId>logback-access</artifactId>
                <version>${ch.qos.logback.version}</version>
            </dependency>
            <dependency>
  <groupId>net.logstash.logback</groupId>
  <artifactId>logstash-logback-encoder</artifactId>
  <version>4.4</version>
</dependency>
  </dependencies>
</project>

```

logback.xml:  
\<?xml version="1.0" encoding="UTF-8"?\>

```
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder charset="UTF-8"> 
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n
            </pattern>
        </encoder>
    </appender>
    <appender name="stash" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<!-- <destination>172.16.10.5:8805</destination> -->
         <remoteHost>172.16.10.5</remoteHost>
        <port>8805</port> 

        <!-- encoder is required -->
        <encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder" />
    </appender>

    <!--<appender name="async" class="ch.qos.logback.classic.AsyncAppender">-->
        <!--<appender-ref ref="stash" />-->
    <!--</appender>-->

    <root level="info">                    
        <appender-ref ref="STDOUT" />
        <appender-ref ref="stash" />
    </root>
</configuration>

```

logstash config:  
input {  
stdin {}  
tcp {  
port =\> 80  
mode =\> "server"  
codec =\> json\_lines  
}  
}  
output {  
stdout { codec =\> rubydebug }  
elasticsearch {  
hosts =\> ["172.16.10.5:8802"]  
index =\> "hd-citos-%{+YYYY.MM.dd}"  
}  
}  
when i try a simple demo .it show nothing.  
but when i use --debug.  
i find sth there:  
[2017-09-13T10:25:35,543][DEBUG][logstash.inputs.tcp] Accepted connection {:client=\>"10.18.12.222:55206", :server=\>"0.0.0.0:80"}  
[2017-09-13T10:25:35,550][DEBUG][logstash.codecs.line] config LogStash::Codecs::Line/@id = "line\_4cbf1e76-e096-419b-b7c9-8a40daa19387"  
[2017-09-13T10:25:35,550][DEBUG][logstash.codecs.line] config LogStash::Codecs::Line/@enable\_metric = true  
[2017-09-13T10:25:35,550][DEBUG][logstash.codecs.line] config LogStash::Codecs::Line/@charset = "UTF-8"  
[2017-09-13T10:25:35,550][DEBUG][logstash.codecs.line] config LogStash::Codecs::Line/@delimiter = "\n"  
[2017-09-13T10:25:35,560][DEBUG][logstash.inputs.tcp] Connection reset by peer {:client=\>"10.18.12.222:55206"}  
can anyone help me ?

---

<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:** [September 13, 2017, 12:03pm UTC](https://discuss.elastic.co/t/input-tcp-error/100336/2 "2017-09-13T12:03:21Z")

</div>

Why have you commented out the `<destination>` tag? And why do you have port 8805 in the Logback configuration when you have port 80 in your Logstash configuration?

---

<div class="post-metadata">

**Author:** ![xiaopeng\_zhang](https://avatars.discourse-cdn.com/v4/letter/x/71e660/32.png) [@xiaopeng\_zhang](https://discuss.elastic.co/u/xiaopeng_zhang)\
**Post date:** [September 13, 2017, 12:56pm UTC](https://discuss.elastic.co/t/input-tcp-error/100336/3 "2017-09-13T12:56:00Z")

</div>

when i use the `<destination>` tag ,the logback report:  
20:53:20,109 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]  
20:53:20,109 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]  
20:53:20,109 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/D:/hd1/log4jlearn/target/classes/logback.xml]  
20:53:20,189 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set  
20:53:20,194 |-ERROR in ch.qos.logback.core.joran.action.PropertyAction - Could not find resource [properties/logback-variables.properties].  
20:53:20,194 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]  
20:53:20,197 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]  
20:53:20,201 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property  
20:53:20,246 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [net.logstash.logback.appender.LogstashTcpSocketAppender]  
20:53:20,255 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [stash]  
20:53:20,256 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@12:22 - no applicable action for [destination], current ElementPath is [[configuration][appender][destination]]  
20:53:20,394 |-ERROR in net.logstash.logback.appender.LogstashTcpSocketAppender[stash] - No remote host was configured for appender stash.  
20:53:20,395 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to INFO  
20:53:20,395 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]  
20:53:20,395 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [stash] to Logger[ROOT]  
20:53:20,395 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.  
20:53:20,396 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@536aaa8d - Registering current configuration as safe fallback point  
so i try to use `<remoteHost>`,  
and my logstash is in docker [container.so](http://container.so) port 80 for docker host is port 8805 ,which i configure it

---

<div class="post-metadata">

**Author:** ![xiaopeng\_zhang](https://avatars.discourse-cdn.com/v4/letter/x/71e660/32.png) [@xiaopeng\_zhang](https://discuss.elastic.co/u/xiaopeng_zhang)\
**Post date:** [September 13, 2017, 3:28pm UTC](https://discuss.elastic.co/t/input-tcp-error/100336/4 "2017-09-13T15:28:54Z")

</div>

[hey.It](http://hey.It) seems that the logstash has no problems.  
because when i use `telnet 172.16.10.5 8805`  
logstash can Receive data [correctly.so](http://correctly.so) i think it that maybe there are some error on sockerAppender.  
It can't connection logstash [correctly.Do](http://correctly.Do) you have any suggeestion about it ?I need some help to use logback send the logs.

---

<div class="post-metadata">

**Author:** ![xiaopeng\_zhang](https://avatars.discourse-cdn.com/v4/letter/x/71e660/32.png) [@xiaopeng\_zhang](https://discuss.elastic.co/u/xiaopeng_zhang)\
**Post date:** [September 14, 2017, 2:15pm UTC](https://discuss.elastic.co/t/input-tcp-error/100336/5 "2017-09-14T14:15:37Z")

</div>

sorry man.....I'm really really noob.  
the logback seems like that it doesn't use some method to ensure the sockerAppender to connect the logstash and send all logs .If the main thread stop correctly when the logback just start to connect the logstash, it will be break off.  
This is the demo:  
import org.slf4j.Logger;  
import org.slf4j.LoggerFactory;

```
public class logbackTest {
	
	 public static final Logger logger=LoggerFactory.getLogger(logbackTest.class);

	    public static void main(String[] args) {
	        logger.debug("This is a debug message!");
	        logger.info("213213421312512321312412512313123");
	        logger.info("This is info message!");
	        logger.warn("This is a warn message!");

```

It will not send the log and the logstash will show Connection reset by peer .  
if add this code under logbackTest:

```
 try {
	            Thread.sleep(10000);
	        } catch (InterruptedException e) {
	            e.printStackTrace(); 
	        }

```

but the error basically does not happen.Because a large program doesn't stop quickly.

---

<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:** [October 12, 2017, 2:15pm UTC](https://discuss.elastic.co/t/input-tcp-error/100336/6 "2017-10-12T14:15:38Z")

</div>

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