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:
committed by
Cameron Sparr
parent
b1a97e35b9
commit
522658bd07
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user