eht16 / python-logstash-async

Python logging handler for sending log events asynchronously to Logstash.
MIT License
182 stars 52 forks source link

Broken TCP connection and endless waiting for events from the dark #83

Closed nazarkhanov closed 1 year ago

nazarkhanov commented 1 year ago

Found a bug which occurres when the connection is broken: the worker waits until the data is sent from the socket. This is my fault. I have no idea how to solve this problem without losing the data that was not sent before closing the socket.

A possible hotfix would be to set a constant timeout to wait for the socket write buffer to clear.

cbeaujoin-stellar commented 1 year ago

Use beat transport, it has an acknowledgment feature

eht16 commented 1 year ago

I implemented a timeout, configurable via constants and with a default of 30 seconds.

@nazarkhanov Do you think 30 seconds are a reasonable default?

Could you maybe test the changes? I tried to reproduce this by rate-limiting outgoing packets to Logstash via iptables. This seemed to work but is a rather artificial case.