From 61ca0286ce3d2a0d651248ea58710058dfdcd8ee Mon Sep 17 00:00:00 2001 From: Kevin Seidel Date: Fri, 6 Sep 2019 10:58:20 +0200 Subject: [PATCH] closing test tcp connections --- CHANGELOG.md | 4 ++++ exporter/main.go | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7743985..943931c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog ## Unreleased +## [0.0.3] 2019-09-06 +### Added +- the tcp connections for testing the connection to the xmpp server are now closed + ## [0.0.2] 2019-09-05 ### Added - the prom exporter now watches the tcp conn to the xmpp server (this led to some confusion on k8s), if the connection to the xmpp server is lost, the exporter exits diff --git a/exporter/main.go b/exporter/main.go index 7d11137..1d9f9ea 100644 --- a/exporter/main.go +++ b/exporter/main.go @@ -128,10 +128,15 @@ func main() { go func() { address := xmppServer + ":" + xmppPort for true { - _, err := net.DialTimeout("tcp", address, 5*time.Second) + conn, err := net.DialTimeout("tcp", address, 5*time.Second) if err != nil { fmt.Printf("Could not connect to server %s: %s\nexiting\n", address, err.Error()) signals <- iExit + return + } + + if tcpconn, ok := conn.(*net.TCPConn); ok { + _ = tcpconn.Close() } time.Sleep(10 * time.Second) }