code: function autoReconnect(options, connectionListener)
  {
  	var reconnectInterval = getOption(options, 'reconnectInterval', 5000);
  
  	var reconnector = new events.EventEmitter();
  
  	function reconnect()
  	{
  		var client = connect(options);
  		var isReconnecting = false;
  		
  		function tryReconnecting()
  		{
  			if ( !isReconnecting )
  			{
  				isReconnecting = true;
  				reconnector.emit('close');
  			}
  		}
  
  		client.on('connect', () => {
  			connectionListener(client);
  		});
  
  		client.on('close', () => {
  			tryReconnecting();
  		});
  
  		client.on('error', (e) => {
  			tryReconnecting();
  		});
  	}
  
  	reconnector.on('close', () => {
  		setTimeout(() => reconnector.emit('reconnect'), reconnectInterval);
  	});
  
  	reconnector.on('reconnect', () => {
  		reconnect();
  	});
  	
  	reconnect();
  }
docs: **********************************************************************************************