@Override
	public void run()
	{
		RUBTConstants.main_log.info("Tracker is up"); 
		while (this.keepRunning)
		{
			RUBTConstants.main_log.info("Tracker sending event " + this.getEvent()); 
			//send http request
			byte[] httpResponseArray = null;
			try {
				httpResponseArray = httpConnectionToTracker();
			} catch (IOException ex) {
				RUBTConstants.main_log.severe("Connecting to tracker failed!");
				//sleep min_interval upon a failed connection to the tracker
				try {
					RUBTConstants.main_log.info("Tracker will go to sleep for " + this.min_interval + " secs"); 
					Thread.sleep(this.min_interval*1000);
				} catch (InterruptedException e) {
					//ignore interrupts
					RUBTConstants.main_log.info("Thread Tracker was interrupted while sleeping!");
				}
			}
			//exit after sending stopped event
			if (this.getEvent().equals(RUBTConstants.EVENT_STOPPED))
			{
				//disconnect tracker
				this.disconnect();
				continue;
			}

			//reset event
			this.setEvent(null);

			//get list of peers
			ArrayList<Peer> onlinePeers = null;
			try {
				onlinePeers = getPeerList(httpResponseArray);
			} catch (BencodingException ex) {
				//sleep min_interval upon failing to get list of peers
				RUBTConstants.main_log.severe("Parsing tracker's response failed!");
				try {
					RUBTConstants.main_log.info("Tracker will go to sleep for " + this.min_interval + " secs"); 
					Thread.sleep(this.min_interval*1000);
				} catch (InterruptedException e) {
					//ignore interrupts
					RUBTConstants.main_log.info("Thread Tracker was interrupted while sleeping!");
				}
			}

			//if we get here all is good
			//announce your listeners that you got a new peer list
			for (RUBTClientListener listener : Tracker.this.listeners) {
				listener.onlinePeersListReady(onlinePeers);
			}

			//then sleep for interval seconds
			try {
				RUBTConstants.main_log.info("Tracker will go to sleep for " + this.interval + " secs"); 
				Thread.sleep(this.interval*1000);
			} catch (InterruptedException e) {
				//ignore interrupts
				RUBTConstants.main_log.info("Thread Tracker was interrupted while sleeping!");
			}
		}
		RUBTConstants.main_log.info("Tracker is down!"); 
		//end session in clients activity log
		RUBTConstants.main_log.info("*** END SESSION ***");
		RUBTConstants.main_log.info("closing activity and stats logs"); 
		//close RUBT log
		RUBTConstants.main_log.getHandlers()[0].close();
		//close STATS log
		RUBTConstants.stats_log.getHandlers()[0].close();
	}