Skip to content

Commit

Permalink
dialers with timeouts (#57)
Browse files Browse the repository at this point in the history
* added Dials with timeouts to deal with dead devices
* bump for version release
  • Loading branch information
nshttpd authored Nov 11, 2019
1 parent 9fc2841 commit 60bb04d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.11-DEVEL
1.0.11
7 changes: 5 additions & 2 deletions collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func (c *collector) connect(d *config.Device) (*routeros.Client, error) {

log.WithField("device", d.Name).Debug("trying to Dial")
if !c.enableTLS {
conn, err = net.Dial("tcp", d.Address+apiPort)
conn, err = net.DialTimeout("tcp", d.Address+apiPort, c.timeout)
if err != nil {
return nil, err
}
Expand All @@ -254,7 +254,10 @@ func (c *collector) connect(d *config.Device) (*routeros.Client, error) {
tlsCfg := &tls.Config{
InsecureSkipVerify: c.insecureTLS,
}
conn, err = tls.Dial("tcp", d.Address+apiPortTLS, tlsCfg)
conn, err = tls.DialWithDialer(&net.Dialer{
Timeout: c.timeout,
},
"tcp", d.Address+apiPortTLS, tlsCfg)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 60bb04d

Please sign in to comment.