Skip to content

Commit

Permalink
closing test tcp connections
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Seidel committed Sep 6, 2019
1 parent b938d3c commit 61ca028
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 6 additions & 1 deletion exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 61ca028

Please sign in to comment.