# curl works but uri module times out.

**URL:** <https://forum.ansible.com/t/curl-works-but-uri-module-times-out/16409>\
**Category:** Ansible Project\
**Created:** [October 2, 2014, 6:57pm UTC](https://forum.ansible.com/t/curl-works-but-uri-module-times-out/16409 "2014-10-02T18:57:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![david.neudorfer](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@david.neudorfer](https://forum.ansible.com/u/david.neudorfer)\
**Post date:** [October 2, 2014, 6:57pm UTC](https://forum.ansible.com/t/curl-works-but-uri-module-times-out/16409/1 "2014-10-02T18:57:32Z")

</div>

curl returns a 200 instantly

`  
$ curl -I -u warby-mgmt:warby-mgmt-password [http://localhost:15672/api/queues/%2F/cep.transactional\_email](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](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](http://localhost:15672/api/queues/%2F/cep.transactional_email)  
`

Any ideas why curl works and uri fails?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [October 2, 2014, 8:58pm UTC](https://forum.ansible.com/t/curl-works-but-uri-module-times-out/16409/2 "2014-10-02T20:58:56Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Romeo\_Theriault](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@Romeo\_Theriault](https://forum.ansible.com/u/Romeo_Theriault)\
**Post date:** [October 2, 2014, 8:59pm UTC](https://forum.ansible.com/t/curl-works-but-uri-module-times-out/16409/3 "2014-10-02T20:59:02Z")

</div>

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....
