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.
To examine the supported platforms, see the list of installer packages in the Available Modules chapter. |
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.
|
|||
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:
|
|||
With this optional directive it is possible to set the maximum number of allowed concurrent/active connections for a listening TCP socket.
If not specified, the default value is 2024-03-01 22:29:16 ERROR [im_tcp|in_tcp] Number of allowed active connections(10) reached: 10. Refusing connection from 127.0.0.1 |
|||
This optional directive defines the maximum time in seconds before NXLog closes TCP connections without traffic. The minimum timeout value is 15 seconds. If this directive is not specified, NXLog does not close idle TCP connections. |
|||
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 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 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>