curl works but uri module times out.

curl returns a 200 instantly

`
$ curl -I -u warby-mgmt:warby-mgmt-password http://localhost:15672/api/queues/%2F/cep.transactional_email
HTTP/1.1 200 OK
Server: MochiWeb/1.1 WebMachine/1.10.0 (never breaks eye contact)
Content-Type: application/json
Content-Length: 1537
Cache-Control: no-cache

`

When I attempt to use the uri module it times out.

`

  • name: Add CEP Rabbit Queues with uri module
    hosts: localhost
    gather_facts: no
    tasks:
  • name: add cep rabbit queues
    uri:
    url=http://{{ hostvars[groups[‘rabbit’][0]].private_ip_address }}:15672/api/queues/%2F/{{ item }}
    method=PUT
    user={{ rabbit_configuration.mgmt_user }}
    password={{ rabbit_configuration.mgmt_user }}
    body=‘{“type”:“direct”,“auto_delete”:false,“durable”:true,“arguments”:}’
    status_code=200
    HEADER_Content-Type=“application/json”
    return_content=yes
    with_items:
  • cep.transactional_email
  • cep.transaction_test

`

`
TASK: [add cep rabbit queues] *************************************************

<10.210.3.38> ESTABLISH CONNECTION FOR USER: mozart

<10.210.3.38> REMOTE_MODULE uri url=http://localhost:15672/api/queues/%2F/cep.transactional_email method=PUT user=warby-mgmt password=VALUE_HIDDEN body=‘{“type”:“direct”,“auto_delete”:false,“durable”:true,“arguments”:}’ status_code=200 HEADER_Content-Type=“application/json”

<10.210.3.38> EXEC [‘ssh’, ‘-C’, ‘-vvv’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=180s’, ‘-o’, ‘ConnectionAttempts=60’, ‘-o’, ‘ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r’, ‘-o’, ‘StrictHostKeyChecking=no’, ‘-o’, ‘Port=22’, ‘-o’, ‘IdentityFile=/root/.ssh/keys/dev’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘User=mozart’, ‘-o’, ‘ConnectTimeout=10’, u’10.210.3.38’, u"/bin/sh -c ‘LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8 /usr/bin/python’"]

failed: [d-rabbit01] => (item=cep.transactional_email) => {“failed”: true, “item”: “cep.transactional_email”}

msg: Socket error: timed out to http://localhost:15672/api/queues/%2F/cep.transactional_email
`

Any ideas why curl works and uri fails?

Hmm, I can’t.

Perhaps usage of something like Charles Proxy (or other free methods) could be used to see whether the network activity was the same.

Any ideas why curl works and uri fails?

Not sure, but a few things I noticed/might try:

* Looks like you're doing a GET with curl and a PUT with uri.

* The error you're getting "Socket error: timed out" sounds like it's
unable to even connect to the port, like the port is closed or something.
We know it's not though, so maybe try changing 'localhost' to an ip-address
the box has to try another route to the listening port....