dialers with timeouts (#57)

* added Dials with timeouts to deal with dead devices
* bump for version release
This commit is contained in:
Steve Brunton 2019-11-11 17:13:46 -05:00 committed by GitHub
parent 9fc2841a61
commit 60bb04d0e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -1 +1 @@
1.0.11-DEVEL 1.0.11

View File

@ -245,7 +245,7 @@ func (c *collector) connect(d *config.Device) (*routeros.Client, error) {
log.WithField("device", d.Name).Debug("trying to Dial") log.WithField("device", d.Name).Debug("trying to Dial")
if !c.enableTLS { if !c.enableTLS {
conn, err = net.Dial("tcp", d.Address+apiPort) conn, err = net.DialTimeout("tcp", d.Address+apiPort, c.timeout)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -254,7 +254,10 @@ func (c *collector) connect(d *config.Device) (*routeros.Client, error) {
tlsCfg := &tls.Config{ tlsCfg := &tls.Config{
InsecureSkipVerify: c.insecureTLS, 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 { if err != nil {
return nil, err return nil, err
} }