cloudfoundry / fluent-plugin-syslog_rfc5424

MIT License
3 stars 17 forks source link

Does not connect to socket using transport: udp #6

Open openface opened 4 years ago

openface commented 4 years ago

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
adepretis commented 2 years ago

can someone make a new release with this fix?

stefanlasiewski commented 2 years ago

Is this project abandoned? the last release was in Dec 26, 2019.

Can anyone recommend a workaround?