public void connect() {
		MongoClientOptions.Builder builder = new MongoClientOptions.Builder();
		//builder.socketTimeout(0);
		builder.socketKeepAlive(true);
		
		boolean notConnected = true;
		
		while (notConnected && !shutdown) {

			try {
				Utils.printWithDate("Connect to MongoDB at " + hostname + " (Port " + port + ") ... ", Utils.DEBUGLEVEL.GENERAL);
				mongoClient = new MongoClient( new ServerAddress(hostname, port), builder.build() );
				
				//cause exceptions if database is not open
				mongoClient.getDatabaseNames();
				
				notConnected = false;			
				
			} catch (Exception e) {
				if (shutdown) return;
				Utils.printWithDate("MongoDB: could not connect to " + hostname + "; retrying ...", Utils.DEBUGLEVEL.WARNING);
			}
		}
		
		if (shutdown) return;
		
		Utils.printWithDate("connected", Utils.DEBUGLEVEL.GENERAL);
		isConnected = true;
	}