Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RabbitMQ failed to start, TCP connection succeeded but Erlang distribution failed

I'm a new one just start to learn and install RabbitMQ on Windows System.

I install Erlang VM and RabbitMQ in custom folder, not default folder (Both of them).

Then I have restarted my computer.

By the way,My Computer name is "NULL"


I cd to the RabbitMQ/sbin folder and use command:

rabbitmqctl status

But the return message is:

Status of node rabbit@NULL ...

Error: unable to perform an operation on node 'rabbit@NULL'. Please see diagnostics information and suggestions below.

Most common reasons for this are:

  • Target node is unreachable (e.g. due to hostname resolution, TCP connection or firewall issues)
  • CLI tool fails to authenticate with the server (e.g. due to CLI tool's Erlang cookie not matching that of the server)
  • Target node is not running

In addition to the diagnostics info below:

  • See the CLI, clustering and networking guides on http://rabbitmq.com/documentation.html to learn more
  • Consult server logs on node rabbit@NULL

DIAGNOSTICS

attempted to contact: [rabbit@NULL]

rabbit@NULL:

  • connected to epmd (port 4369) on NULL
  • epmd reports node 'rabbit' uses port 25672 for inter-node and CLI tool traffic
  • TCP connection succeeded but Erlang distribution failed

  • Authentication failed (rejected by the remote node), please check the Erlang cookie

Current node details:

  • node name: rabbitmqcli70@NULL
  • effective user's home directory: C:\Users\Jerry Song
  • Erlang cookie hash: 51gvGHZpn0gIK86cfiS7vp==

I have try to RESTART RabbitMQ, What I get is:

ERROR: node with name "rabbit" already running on "NULL"


By the way,My Computer name is "NULL" And I have enable all ports in firewall.

like image 740
nthack Avatar asked Dec 18 '17 19:12

nthack


3 Answers

https://groups.google.com/forum/#!topic/rabbitmq-users/a6sqrAUX_Fg describes the problem where there is a cookie mismatch on a fresh installation of Rabbit MQ. The easy solution on windows is to synchronize the cookies

Also described here: http://www.rabbitmq.com/clustering.html#erlang-cookie

Ensure cookies are synchronized across 1, 2 and Optionally 3 below

  1. %HOMEDRIVE%%HOMEPATH%\.erlang.cookie (usually C:\Users\%USERNAME%\.erlang.cookie for user %USERNAME%) if both the HOMEDRIVE and HOMEPATH environment variables are set

  2. %USERPROFILE%\.erlang.cookie (usually C:\Users\%USERNAME%\.erlang.cookie) if HOMEDRIVE and HOMEPATH are not both set

  3. For the RabbitMQ Windows service - %USERPROFILE%\.erlang.cookie (usually C:\WINDOWS\system32\config\systemprofile)

The cookie file used by the Windows service account and the user running CLI tools must be synchronized by copying the one from C:\WINDOWS\system32\config\systemprofile folder.

like image 166
Rishabh Jain Avatar answered Oct 23 '22 23:10

Rishabh Jain


If you are using dedicated drive folder locations for your development tools/software in Windows10(Not the windows default location), one way you can synchronize the erlang cookie as described by https://www.rabbitmq.com/cli.html is by copying the cookie as explained below.

Please note in my case HOMEDRIVE and HOMEPATH environment variables both are not set.


After copying the "C:\Windows\system32\config\systemprofile\.erlang.cookie" to "C:\Users\%USERNAME%\.erlang.cookie" ,

the error "tcp connection succeeded but Erlang distribution failed" is resolved.


Now I am able to use "rabbitmqctl.bat status" command successfully. Hence there is no mandatory need to install in default location to resolve this error as synchronizing cookie will resolve that error.

like image 14
ilanuk Avatar answered Oct 24 '22 00:10

ilanuk


In my case similar issue (Authentication failed because of Erlang cookies mismatch) solved by copying .erlang.cookie file from Windows system dir - C:\Windows\system32\config\systemprofile\.erlang.cookie to %HOMEDRIVE%%HOMEPATH%\.erlang.cookie (where %HOMEDRIVE% was set to H: and %HOMEPATH% to \ respectively)

Quick setup TODO for Windows, Erlang OTP 24 and RabbitMQ 3.8.19:

  1. Download & Install Erlang [OTP 24] (needs Admin rights) from: https://www.erlang.org/downloads
  2. set ERLANG_HOME (should point to install dir)
  3. Download & Install recent [3.8.19] RabbitMQ (needs Admin rights) from: https://github.com/rabbitmq/rabbitmq-server/releases/
  4. Follow: https://www.rabbitmq.com/install-windows.html and/or https://www.rabbitmq.com/install-windows-manual.html
  5. set RABBITMQ_SERVER (should point to install dir)
  6. update %PATH% by adding: ;%RABBITMQ_SERVER%\sbin
  7. Fix Erlang-cookie issue from above, follow: https://www.rabbitmq.com/cli.html#erlang-cookie
  8. Enable Web UI by running command: %RABBITMQ_SERVER%/sbin/rabbitmq-plugins.bat enable rabbitmq_management
  9. From item #8 (above) got error because of missing file: %USERPROFILEDIR%/AppData/Roaming/RabbitMQ/enabled_plugins -> had to create it and run %RABBITMQ_SERVER%/sbin/rabbitmq-plugins.bat enable rabbitmq_management again!
  10. Run/restart on the way might be required
  11. Finally, login to: http://localhost:15672/ (guest:guest) RabbitMQ web UI

, or check by cURL: curl -i -u guest:guest http://localhost:15672/api/vhosts should receive response like:

        HTTP/1.1 200 OK
    cache-control: no-cache
    content-length: 186
    content-security-policy: script-src 'self' 'unsafe-eval' 'unsafe-inline'; 
    object-src 'self'
    content-type: application/json
    date: Tue, 13 Jul 2021 11:21:12 GMT
    server: Cowboy
    vary: accept, accept-encoding, origin
        [{"cluster_state":{"rabbit@hostname":"running"},"description":"Default virtual host","metadata":{"description":"Default virtual host","tags":[]},"name":"/","tags":[],"tracing":false}]

P.S. Some useful RabbitMQ CLI commands (copy-paste):

  • %RABBITMQ_SERVER%/sbin/rabbitmqctl start_app
  • %RABBITMQ_SERVER%/sbin/rabbitmqctl stop_app
  • %RABBITMQ_SERVER%/sbin/rabbitmqctl status

P.P.S. UPDATE: great article for this subject: https://www.journaldev.com/11655/spring-rabbitmq

like image 5
Taras Buha Avatar answered Oct 24 '22 00:10

Taras Buha