def start_listening

      begin
        # http client instantiation and configuration
        http_client = Net::HTTP.new(@host, @port)
        logger.debug("#{self.class} opening connection to  #{@host}:#{@port}")
        http_client.use_ssl = @scheme.eql?("https")
        if @scheme.eql?("https")
          http_client.verify_mode = OpenSSL::SSL::VERIFY_NONE
        end

        logger.debug("#{self.class} start listening to stream #{@path}")

        http_client.read_timeout = 60*6 # double the timeout connFu is configured

        # open connection
        http_client.start do |http|
          req = Net::HTTP::Get.new(
              @path,
              headers)

          # send GET request
          http.request(req) do |res|
            logger.debug "#{self.class} Request to the endpoint...."
            # read chunk data
            logger.debug "#{self.class} Waiting for a new event...."
            res.read_body do |chunk|
              unless chunk.chomp.strip.empty?
                # format data retrieved
                events = handle_data(chunk)
                # Insert message(s) in the queue
                events.nil? or message(events)
              else
                logger.debug "#{self.class} got an empty data"
              end
              logger.debug "#{self.class} Waiting for a new event...."
            end
          end
        end
      rescue Exception => ex
        logger.error "[#{Time.now} | #{ex.class}] #{ex.message}\n#{ex.backtrace.join("\n")}"
        # loop again
        start_listening
      end
    end
def start_listening

      begin
        # http client instantiation and configuration
        http_client = Net::HTTP.new(@host, @port)
        logger.debug("#{self.class} opening connection to  #{@host}:#{@port}")
        http_client.use_ssl = @scheme.eql?("https")
        if @scheme.eql?("https")
          http_client.verify_mode = OpenSSL::SSL::VERIFY_NONE
        end

        logger.debug("#{self.class} start listening to stream #{@path}")

        http_client.read_timeout = 60*6 # double the timeout connFu is configured

        # open connection
        http_client.start do |http|
          req = Net::HTTP::Get.new(
              @path,
              headers)

          # send GET request
          http.request(req) do |res|
            logger.debug "#{self.class} Request to the endpoint...."
            # read chunk data
            logger.debug "#{self.class} Waiting for a new event...."
            res.read_body do |chunk|
              unless chunk.chomp.strip.empty?
                # format data retrieved
                events = handle_data(chunk)
                # Insert message(s) in the queue
                events.nil? or message(events)
              else
                logger.debug "#{self.class} got an empty data"
              end
              logger.debug "#{self.class} Waiting for a new event...."
            end
          end
        end
      rescue Exception => ex
        logger.error "[#{Time.now} | #{ex.class}] #{ex.message}\n#{ex.backtrace.join("\n")}"
        # loop again
        start_listening
      end
    end
application logger

 ConnfuStream initializer.
 ==== Parameters

 * +app_stream+ valid HTTP stream url to connect and listen events
 * +api_key+ valid Token to get access to a Connfu Stream
 * +uri+ HTTP endpoint to open the connection

 Open a HTTP connection to connFu and start listening new events