# Logstash TCP Input Codec to set utf-16 is not working

**URL:** https://discuss.elastic.co/t/logstash-tcp-input-codec-to-set-utf-16-is-not-working/166318
**Category:** Logstash
**Created:** [January 30, 2019, 9:27am UTC](https://discuss.elastic.co/t/logstash-tcp-input-codec-to-set-utf-16-is-not-working/166318 "2019-01-30T09:27:26Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![aliaramli](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@aliaramli](https://discuss.elastic.co/u/aliaramli)
#### Post date: [January 30, 2019, 9:27am UTC](https://discuss.elastic.co/t/logstash-tcp-input-codec-to-set-utf-16-is-not-working/166318/1 "2019-01-30T09:27:27Z")

</div>

Hi,

I wanted to set the input tcp plugin to have codec charset utf-16, because one of the logs has Chinese characters.

`[2019-01-30T09:23:25,617][WARN][logstash.codecs.line] Received an event that has a different character encoding than you configured. {:text=>"<13>Jan 30 09:23:21 whatever.com 856\\t52\\t-\\t-\\t{\\\"publis\\\":\\\"ww\\\",\\\"ho\\\":\\\"w.com\\\",\\\"pub\\\":\\\"52\\\",\\\"date\\\":\\\"2019-01-30 09:23:21\\\",\\\"request_method\\\":\\\"GET\\\",\\\"content_length\\\":\\\"-\\\",\\\"content_type\\\":\\\"text/html\\\",\\\"cache_control\\\":\\\"-\\\",\\\"upst\\\":\\\"1164:80\\\",\\\"sc\\\":\\\"ht.232\\\",\\\"doci\\\":\\\"/aur/̸Ц\\xB2\\xBB\\xB7\\xE7\\xC9\\xFA\\\",\\\"upus\\\":\\\"200\\\",\\\"ed\\\":\\\"1717\\\",\\\"cac\\\":\\\"EXP\\\",\\\"op\\\":\\\"85\\\"}", :expected_charset=>"UTF-8"}`

Unfortunately, my setup doesnt work.... the same error still showing

```
input {
  tcp {
    port => 15140
    type => "default"
    codec => plain {
      charset => "UTF-16"
    }   
  }
}

```

Please help.

---

<div class="post-metadata">

### Author: ![danhermann](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danhermann/32/33024_2.png) [@danhermann](https://discuss.elastic.co/u/danhermann)
#### Post date: [January 30, 2019, 11:06am UTC](https://discuss.elastic.co/t/logstash-tcp-input-codec-to-set-utf-16-is-not-working/166318/2 "2019-01-30T11:06:08Z")

</div>

@aliaramli, are you sure that error message is the result of events you're receiving through the TCP input because your config shows the TCP input configured with the `plain` codec and the warning message above is from the `line` codec.

---

<div class="post-metadata">

### Author: ![aliaramli](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@aliaramli](https://discuss.elastic.co/u/aliaramli)
#### Post date: [January 31, 2019, 3:14am UTC](https://discuss.elastic.co/t/logstash-tcp-input-codec-to-set-utf-16-is-not-working/166318/3 "2019-01-31T03:14:07Z")

</div>

I ve changed to codec line, same issue still persist. Hmm if its not coming from tcp event, where could it come from? As i only set to accept input from tcp

```
  input {
      tcp {
        port => 15140
        type => "default"
        codec => line {
         charset => "UTF-16"
         }   
       }
      }
```

---

<div class="post-metadata">

### Author: ![danhermann](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danhermann/32/33024_2.png) [@danhermann](https://discuss.elastic.co/u/danhermann)
#### Post date: [January 31, 2019, 12:26pm UTC](https://discuss.elastic.co/t/logstash-tcp-input-codec-to-set-utf-16-is-not-working/166318/4 "2019-01-31T12:26:17Z")

</div>

I'd suggest gathering more information by running with a higher log level (use `--log.level debug` on the command line or its equivalent) and posting several of the logging lines before and after the error you're encountering.

---

<div class="post-metadata">

### Author: ![aliaramli](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@aliaramli](https://discuss.elastic.co/u/aliaramli)
#### Post date: [January 31, 2019, 3:01pm UTC](https://discuss.elastic.co/t/logstash-tcp-input-codec-to-set-utf-16-is-not-working/166318/5 "2019-01-31T15:01:14Z")

</div>

Thank you so much, after running the debug mode, i noticed that its coming from another TCP input on different port.....which was defined in another separate config file.....  
Thanks! managed to set the charset to utf-16 already!

---

<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: [February 28, 2019, 3:01pm UTC](https://discuss.elastic.co/t/logstash-tcp-input-codec-to-set-utf-16-is-not-working/166318/6 "2019-02-28T15:01:17Z")

</div>

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