Description
When using the example with fluentd listening locally if you add Async or Async connect the message "Unable to send logs to fluentd, reconnecting..." is printed out but an strace shows that no connection is ever made.
package main
import (
"fmt"
"log"
"time"
"github.com/fluent/fluent-logger-golang/fluent"
)
func main() {
logger, err := fluent.New(fluent.Config{FluentPort: 24224, FluentHost: "127.0.0.1", Async: true,
MaxRetry: -1,
})
if err != nil {
fmt.Println(err)
}
defer logger.Close()
tag := "myapp.access"
var data = map[string]string{
"foo": "bar",
"hoge": "hoge"}
for i := 0; i < 100; i++ {
e := logger.Post(tag, data)
if e != nil {
log.Println("Error while posting log: ", e)
} else {
log.Println("Success to post log")
}
time.Sleep(1000 * time.Millisecond)
}
}
## Output without async options
2024/10/11 12:35:31 Success to post log
2024/10/11 12:35:32 Success to post log
2024/10/11 12:35:33 Success to post log
2024/10/11 12:35:34 Success to post log
2024/10/11 12:35:35 Success to post log
## Output with asyncConnect
fluent#New: AsyncConnect is now deprecated, please use Async instead2024/10/11 12:37:20 Success to post log
[2024-10-11T12:37:20Z] Unable to send logs to fluentd, reconnecting...
2024/10/11 12:37:21 Success to post log
[2024-10-11T12:37:21Z] Unable to send logs to fluentd, reconnecting...
2024/10/11 12:37:22 Success to post log
[2024-10-11T12:37:22Z] Unable to send logs to fluentd, reconnecting...
2024/10/11 12:37:23 Success to post log
[2024-10-11T12:37:23Z] Unable to send logs to fluentd, reconnecting...
## Output as per the code sample
2024/10/11 12:37:53 Success to post log
[2024-10-11T12:37:53Z] Unable to send logs to fluentd, reconnecting...
2024/10/11 12:37:54 Success to post log
[2024-10-11T12:37:54Z] Unable to send logs to fluentd, reconnecting...
2024/10/11 12:37:55 Success to post log
[2024-10-11T12:37:55Z] Unable to send logs to fluentd, reconnecting...
2024/10/11 12:37:56 Success to post log
[2024-10-11T12:37:56Z] Unable to send logs to fluentd, reconnecting...