Cannot connect to remote rabbitmq server through pika

1,075 views
Skip to first unread message

Mayank Thapliyal

unread,
Jan 5, 2017, 5:46:45 AM1/5/17
to Pika

I have been connecting to rabbitmq in localhost and works fine, but while connecting to a remote server it is giving a Connection closed exception

  File "/Users/mayankt/Documents/work/temporary/courier.py", line 82, in connect_to_mq
    host=exchange_host, port=exchange_port, credentials=credentials))
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pika/adapters/blocking_connection.py", line 339, in __init__
    self._process_io_for_connection_setup()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pika/adapters/blocking_connection.py", line 374, in _process_io_for_connection_setup
    self._open_error_result.is_ready)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pika/adapters/blocking_connection.py", line 395, in _flush_output
    raise exceptions.ConnectionClosed()
pika.exceptions.ConnectionClosed

The value of _open_error_result object in the method _process_io_for_connection_setup is showing connection timeout
'Connection to 10.0.1.47:5672 failed: timeout'

The server's web managerment tool is working, and i am trying a non guest user account with admin privileges.

Need help urgently, thanks for support ..

Stuart Longland

unread,
Jan 7, 2017, 5:20:01 PM1/7/17
to pika-...@googlegroups.com
On 05/01/17 20:46, Mayank Thapliyal wrote:
> The value of _open_error_result object in the method
> _process_io_for_connection_setup is showing connection timeout
> 'Connection to 10.0.1.47:5672 failed: timeout'
>
> The server's web managerment tool is working.

That to me suggests something is blocking connections to port 5672/tcp.

Check the configuration of all routers and firewalls between your Python
process and the AMQP broker process as there is a misconfiguration on at
least one of them that prevents successful contact.
--
Stuart Longland (aka Redhatter, VK4MSL)

I haven't lost my mind...
...it's backed up on a tape somewhere.

rohit vernekar

unread,
Feb 3, 2017, 8:03:07 AM2/3/17
to Pika
try using socket_timeout while creating connection

```
self.connection = pika.BlockingConnection(pika.ConnectionParameters(
                                                                                                        host=host, port=port,
                                                                                                        virtual_host=virtual_host,
                                                                                                        credentials=credentials, socket_timeout=5)
                                                                                                       )
```
Reply all
Reply to author
Forward
0 new messages