public void connect(boolean useXMPPConnection){
		if (useXMPPConnection) {

			Utils.printWithDate("XMPP Connection to: " + hostXMPP + " (Port " + portXMPP + ") ... ", Utils.DEBUGLEVEL.GENERAL);

			ConnectionConfiguration xmppConfig = new ConnectionConfiguration(hostXMPP, portXMPP);
			xmppConfig.setReconnectionAllowed(true);
			loadCertificate(xmppConfig);
			
			connection = new XMPPTCPConnection(xmppConfig);

			boolean retryConnection = true;
			
			while (retryConnection && !shutdown) {
				try {
					connection.connect();
					connection.login(usernameXMPP, passwordXMPP);
	
					Presence p = new Presence(Presence.Type.available);
					p.setStatus("Recommender available");
					connection.sendPacket(p);
	
					Utils.printWithDate("connected", Utils.DEBUGLEVEL.GENERAL);
					retryConnection = false;
	
				} catch (SmackException | IOException | XMPPException e) {
					e.printStackTrace();
				}
			}
			
			if (shutdown) return;
			
			initializePubSubConnection();
			
		} else {
			System.out.println("-------------NO CONNECTION TO XMPP SERVER-------------");
		}
	}