Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NATS plug-ins reconnection logic #1955

Merged
merged 3 commits into from
Oct 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 7 additions & 0 deletions plugins/inputs/nats_consumer/nats_consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
11 changes: 10 additions & 1 deletion plugins/outputs/nats/nats.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down