TCP (im_tcp)
This module accepts TCP connections on the configured address and port. It can handle multiple simultaneous connections. The TCP transfer protocol provides more reliable log transmission than UDP. If security is a concern, consider using the im_ssl module instead.
Configuration
The im_tcp module accepts the following directives in addition to the common module directives.
Optional directives
The module will accept connections on this IP address or DNS hostname.
For security, the default listen address is The port number can be defined by appending it at the end of the hostname or IP address using a colon as a separator ( To listen on multiple addresses or ports in a single module instance, this directive can be repeated multiple times. Both IPv4 and IPv6 addresses are supported. If a DNS name is used, the number of addresses or cnames should be kept below 16 to avoid potential issues caused by DNS response size limits.
|
|||
The module will listen for incoming connections on this port number. The default port is 514 if this directive is not specified. |
|||
This optional directive can be used to allow IP addresses and/or networks to connect. The directive can be set multiple times to add different IPs or networks to allow. This directive is only active when the ListenAddr directive is present. In the absence of this directive, the BlockIP directive is considered. If both AllowIP and BlockIP are absent, then hosts are not restricted from connecting to a listening module. The following formats may be used for the AllowIP directive:
|
|||
This optional directive can be used to deny IP addresses and/or networks to connect. The directive can be set multiple times to add different IPs or networks to deny. This directive is only active when the ListenAddr directive is present. In the absence of this directive, the AllowIP directive is considered. If both AllowIP and BlockIP are absent, then hosts are not restricted from connecting to a listening module. The following formats may be used for the BlockIP directive:
|
|||
This optional boolean directive specifies whether the module instance should exclusively bind to the specified port.
The default value is
|
|||
This optional boolean directive determines whether the module instance should forcibly bind to a port already in use.
The default value is |
|||
This optional boolean directive specifies whether multiple im_tcp module instances can listen on the same port.
When you enable this directive, multiple instances run in a separate thread, allowing NXLog Agent to process incoming logs simultaneously.
See the examples below.
The default value is
|
TCP connections are kept alive by keep-alive packets. This feature is enabled by default and cannot be disabled. |
Examples
With this configuration, NXLog Agent listens for TCP connections on port 1514 and writes the received log messages to a file.
<Input tcp>
Module im_tcp
ListenAddr 0.0.0.0:1514
</Input>
<Output file>
Module om_file
File "tmp/output"
</Output>
<Route tcp_to_file>
Path tcp => file
</Route>
The configuration below provides two im_tcp module instances to reuse port 1514 via the ReusePort directive.
Received messages are written to the /tmp/output
file.
<Input tcp_one>
Module im_tcp
ListenAddr 192.168.31.11:1514
ReusePort TRUE
</Input>
<Input tcp_two>
Module im_tcp
ListenAddr 192.168.31.11:1514
ReusePort TRUE
</Input>