aiidateam / aiida-core

The official repository for the AiiDA code
https://aiida-core.readthedocs.io
Other
427 stars 186 forks source link

Issue connecting to rabbitmq #5953

Closed ireaml closed 11 months ago

ireaml commented 1 year ago

Describe the bug

I had a working installation of aiida which haven't used in the last ~3 weeks, but today when I tried to use it, aiida couldn't connect to rabbitmq (version 3.11.12, with the configuration file modified as described in the documentation). It used to work fine a couple of weeks ago so not sure what happened.

Output of verdi status:

❯ verdi status                                                                                                             4s  aiida_23_03
 ✔ version:     AiiDA v2.2.2
 ✔ config:      /Users/ireaml/.aiida
 ✔ profile:     ml_defects
 ✔ storage:     Storage for 'ml_defects' [open] @ postgresql://aiida_qs_ireaml_4e5ef90831a00836fcf7a502ed3350fd:***@localhost:5432/ml_defects_ireaml_4e5ef90831a00836fcf7a502ed3350fd / DiskObjectStoreRepository: 4804911bec764258a5a4eab40fcfafb3 | /Users/ireaml/.aiida/repository/ml_defects/container
 ✘ rabbitmq:    Unable to connect to rabbitmq with URL: amqp://guest:guest@127.0.0.1:5672?heartbeat=600
Error: ConnectionResetError: [Errno 54] Connection reset by peer
 ⏺ daemon:      The daemon is not running

I tried to uninstall and reinstall rabbitmq using homebrew but aiida still couldn't connect. When running rabbitmq-diagnostics status, everything seems ok to me (output below). Also tried to create a new conda environment, and install aiida-core but still the same issue.

Thanks in advance!

Your environment

Additional context

Output of rabbitmq-diagnostics status:

❯ rabbitmq-diagnostics status

abbitmq-diagnostics status                                                                                                  aiida_23_03
Status of node rabbit@localhost ...
Runtime

OS PID: 1957
OS: macOS
Uptime (seconds): 775
Is under maintenance?: false
RabbitMQ version: 3.11.12
RabbitMQ release series support status: supported
Node name: rabbit@localhost
Erlang configuration: Erlang/OTP 25 [erts-13.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns] [dtrace]
Crypto library: OpenSSL 1.1.1t  7 Feb 2023
Erlang processes: 447 used, 1048576 limit
Scheduler run queue: 1
Cluster heartbeat timeout (net_ticktime): 60

Plugins

Enabled plugin file: /usr/local/etc/rabbitmq/enabled_plugins
Enabled plugins:

 * rabbitmq_mqtt
 * rabbitmq_stream
 * rabbitmq_stomp
 * rabbitmq_stream_common
 * rabbitmq_amqp1_0
 * rabbitmq_management
 * amqp_client
 * rabbitmq_web_dispatch
 * cowboy
 * cowlib
 * rabbitmq_management_agent

Data directory

Node data directory: /usr/local/var/lib/rabbitmq/mnesia/rabbit@localhost
Raft data directory: /usr/local/var/lib/rabbitmq/mnesia/rabbit@localhost/quorum/rabbit@localhost

Config files

Log file(s)

 * /usr/local/var/log/rabbitmq/rabbit@localhost.log
 * /usr/local/var/log/rabbitmq/rabbit@localhost_upgrade.log
 * <stdout>

Alarms

(none)

Memory

Total memory used: 0.1432 gb
Calculation strategy: rss
Memory high watermark setting: 0.4 of available memory, computed to: 13.7439 gb

reserved_unallocated: 0.0692 gb (48.35 %)
code: 0.0363 gb (25.35 %)
other_proc: 0.0297 gb (20.74 %)
other_system: 0.0182 gb (12.7 %)
other_ets: 0.0029 gb (2.03 %)
plugins: 0.0027 gb (1.86 %)
atom: 0.0015 gb (1.03 %)
binary: 0.0013 gb (0.93 %)
metrics: 0.0011 gb (0.75 %)
mgmt_db: 0.0002 gb (0.15 %)
mnesia: 0.0001 gb (0.05 %)
msg_index: 0.0 gb (0.02 %)
quorum_ets: 0.0 gb (0.02 %)
queue_procs: 0.0 gb (0.01 %)
connection_other: 0.0 gb (0.0 %)
quorum_queue_dlx_procs: 0.0 gb (0.0 %)
quorum_queue_procs: 0.0 gb (0.0 %)
stream_queue_procs: 0.0 gb (0.0 %)
stream_queue_replica_reader_procs: 0.0 gb (0.0 %)
allocated_unused: 0.0 gb (0.0 %)
connection_channels: 0.0 gb (0.0 %)
connection_readers: 0.0 gb (0.0 %)
connection_writers: 0.0 gb (0.0 %)
queue_slave_procs: 0.0 gb (0.0 %)
stream_queue_coordinator_procs: 0.0 gb (0.0 %)

File Descriptors

Total: 3, limit: 159
Sockets: 0, limit: 141

Free Disk Space

Low free disk space watermark: 0.05 gb
Free disk space: 1853.7967 gb

Totals

Connection count: 0
Queue count: 1
Virtual host count: 1

Listeners

Interface: [::], port: 15672, protocol: http, purpose: HTTP API
Interface: [::], port: 61613, protocol: stomp, purpose: STOMP
Interface: [::], port: 5552, protocol: stream, purpose: stream
Interface: [::], port: 1883, protocol: mqtt, purpose: MQTT
Interface: [::], port: 25672, protocol: clustering, purpose: inter-node and CLI tool communication
Interface: 127.0.0.1, port: 5672, protocol: amqp, purpose: AMQP 0-9-1 and AMQP 1.0
ltalirz commented 11 months ago

Thanks for this well-written bug report, and sorry that it did not receive any follow-up.

I suspect part of the reason may be that it is difficult to know what exactly changed. I guess ps -ef | grep -i rabbitmq shows the server running?

To disentangle the issue from AiiDA you could consider trying to connect via a Python script, something like

import asyncio
import aio_pika

async def main():
    try:
        # Connect to RabbitMQ running on localhost
        connection = await aio_pika.connect_robust(
                "amqp://guest:guest@127.0.0.1:5672/"
        )

        # Create a channel
        channel = await connection.channel()

        print("Successfully connected as guest via the AMQP interface.")

        await channel.close()
        await connection.close()

    except Exception as e:
        print(f"Failed to connect as guest via the AMQP interface. Error: {e}")

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())

I am going to close this issue now in the assumption it is related to the rabbitmq installation. However, feel free to reopen if there is indeed an issue with AiiDA's connection to rabbitmq (or if the AiiDA documentation should be updated to include more details on how to install rabbitmq on MacOS).