Fix NATS plug-ins reconnection logic (#1955)
* NATS output plug-in now retries to reconnect forever after a lost connection. * NATS input plug-in now retries to reconnect forever after a lost connection. * Fixes #1953
This commit is contained in:
parent
b1a97e35b9
commit
522658bd07
|
@ -43,6 +43,7 @@ continue sending logs to /var/log/telegraf/telegraf.log.
|
|||
|
||||
### Bugfixes
|
||||
|
||||
- [#1955](https://github.com/influxdata/telegraf/issues/1955): Fix NATS plug-ins reconnection logic.
|
||||
- [#1926](https://github.com/influxdata/telegraf/issues/1926): Fix toml unmarshal panic in Duration objects.
|
||||
- [#1746](https://github.com/influxdata/telegraf/issues/1746): Fix handling of non-string values for JSON keys listed in tag_keys.
|
||||
- [#1628](https://github.com/influxdata/telegraf/issues/1628): Fix mongodb input panic on version 2.2.
|
||||
|
|
|
@ -91,8 +91,15 @@ func (n *natsConsumer) Start(acc telegraf.Accumulator) error {
|
|||
|
||||
var connectErr error
|
||||
|
||||
// set default NATS connection options
|
||||
opts := nats.DefaultOptions
|
||||
|
||||
// override max reconnection tries
|
||||
opts.MaxReconnect = -1
|
||||
|
||||
// override servers if any were specified
|
||||
opts.Servers = n.Servers
|
||||
|
||||
opts.Secure = n.Secure
|
||||
|
||||
if n.Conn == nil || n.Conn.IsClosed() {
|
||||
|
|
|
@ -62,14 +62,23 @@ func (n *NATS) SetSerializer(serializer serializers.Serializer) {
|
|||
|
||||
func (n *NATS) Connect() error {
|
||||
var err error
|
||||
// set NATS connection options
|
||||
|
||||
// set default NATS connection options
|
||||
opts := nats_client.DefaultOptions
|
||||
|
||||
// override max reconnection tries
|
||||
opts.MaxReconnect = -1
|
||||
|
||||
// override servers, if any were specified
|
||||
opts.Servers = n.Servers
|
||||
|
||||
// override authentication, if any was specified
|
||||
if n.Username != "" {
|
||||
opts.User = n.Username
|
||||
opts.Password = n.Password
|
||||
}
|
||||
|
||||
// override TLS, if it was specified
|
||||
tlsConfig, err := internal.GetTLSConfig(
|
||||
n.SSLCert, n.SSLKey, n.SSLCA, n.InsecureSkipVerify)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue