code: function reconnect() {
    client.end(false, function () {
      console.log('Reconnecting client: ' + clientId);
      client.connect(url, { 'clientId': clientId });
    });
  }
docs: reconnect Reconnect to your broker