vendredi 9 août 2019

Net::HTTP::Get.new(uri) undefined method `request_uri' RabbitMq amqp

I want to access my rabbitmq docker container through another docker application container but I am getting the following error.

I get the error at request = Net::HTTP::Get.new(uri)

my uri string is

CLOUDAMQP_URL=amqp://guest:guest@rabbitmq:5672/%2F

def collect
      logger.info "Test 1"
      Net::HTTP.start(uri.host, uri.port, use_ssl: secure?) do |http|
        logger.info "Test 2"
        logger.info "Test URI"
        request = Net::HTTP::Get.new(uri)
        logger.info "Test URI"
        request["Accept"] = "application/json"

        request.basic_auth(uri.user, uri.password) if uri.user || uri.password
        logger.info "Test 3"
        response = http.request(request) # Net::HTTPResponse object
        logger.info "Test 4 #{request}"
        response = JSON.parse(response.body)
        response.each do |queue|
          # We're not interested in temporary queues: skip them
          # by detecting the auto_delete flag
          next if queue.fetch("auto_delete")

          name = queue.fetch("name")
          aggregator.gauge("#{name}.messages_count", queue.fetch("messages", 0))
          aggregator.gauge("#{name}.messages_rate", queue.fetch("messages_details", {}).fetch("rate", 0.0))
          aggregatr.gauge("#{name}.consumers_count", queue.fetch("consumers", 0))
        end

[ERROR] rescue: NoMethodError undefined method `request_uri' for #<URI::Generic amqp://guest:guest@rabbitmq:5672/api/queues>

I need the application to run successfully and connect to rabbitmq server

Aucun commentaire:

Enregistrer un commentaire