nathanaelle/syslog5424

syslog.Dial doesn't return error on closed tcp port

Closed this issue · 6 comments

When I try to send a message on a closed syslog server I can't handle the error because Dial is not providing any errors indicating that the socket is closed.

I only get a failure when sending a message but I can't find a way to get an error from it to handle it.

This is what I get before my code exits:

2017/11/02 14:08:26 dial tcp [::1]:5140: getsockopt: connection refused

the real Dial is call in a goroutine.
I don't use directly a net.Conn but I use an interface that provide a Redial() func.

I need to think for a way to provide some feed back.

I may have a solution …
I will write it on monday.

I didn't forget…

I must correct 1 remaining error before pushing the code.

my misconception (exactly a forgotten TODO) is trivial here :

  1. it's a TODO , so let's do it later (and forget it)
  2. if an error occurs in a goroutine, there is no way to get it except with the panic/defer/recover pattern.

the coded solution is :

  1. rewrite the code, and introduce some breaking change in the creation
  2. provide wrapper to ease the migration with the breaking change
  3. provide a chan error so you can catch any error in goroutine and decide what to do with them

two panic() remain in listener-unixgram.go .
there is a new issue with unixgram collector because, unixgramdoesn't support writev() syscall (introduced with my rewrite).

I want to drop the unixgram code but unixgram are AF_UNIX Datagram (UDP equivalent) and some unix systems still need them in 2017 😤

if the code is fine for you, I will correct the import paths and release it as v0.2