Skip to content

Does not connect to socket using transport: udp  #6

Description

@openface

Using udp transport, I've narrowed down the issue to the following:

The UDPSocket is created here: https://github.com/cloudfoundry/fluent-plugin-syslog_rfc5424/blob/main/lib/fluent/plugin/out_syslog_rfc5424.rb#L53

@sockets[socket_key(transport, host, port)] = socket_create(transport.to_sym, host, port, socket_options)

This passes in socket_options which return {}.

https://github.com/cloudfoundry/fluent-plugin-syslog_rfc5424/blob/main/lib/fluent/plugin/out_syslog_rfc5424.rb#L57

But in order for this to work with UDPSocket, we have to explicitly tell fluent'd helper socket_create to pass connect: true as an option.

https://github.com/fluent/fluentd/blob/master/lib/fluent/plugin_helper/socket.rb#L81

Notice that connect argument defaults to false.

So this results in the following error:

2020-08-19 19:40:03 +0000 [warn]: #0 fluent/log.rb:348:warn: failed to flush the buffer. retry_time=0 next_retry_seconds=2020-08-19 19:40:04 +0000 chunk="5ad402ade8c90acdc250f30fc886a360" error_class=Errno::EDESTADDRREQ error="Destination address required"

Because the socket is not connected.

Changing the socket_options method to pass connect: true when @transport == 'udp' fixes this.

def socket_options
  if @transport == 'udp'
    { connect: true }
  elsif @transport == 'tls'
    # TODO: make timeouts configurable
    { insecure: @insecure, verify_fqdn: !@insecure, cert_paths: @trusted_ca_path } #, connect_timeout: 1, send_timeout: 1, recv_timeout: 1, linger_timeout: 1 }
  else
    {}
  end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions