2
votes

I used amqp client to connect ActiveMQ broker.

import amqp

USER = "guest"
PASSWORD = "guest"
HOST = 'localhost'
PORT = '5672'

host = HOST + ":" + PORT

conn = amqp.connection.Connection(host=host,userid=USER,password=PASSWORD,login_method='AMQPLAIN',ssl=True)
conn.connect()

Getting error : OSError: Server unexpectedly closed connection

2
I am a big fan of pika.readthedocs.io/en/stable the pika library for amqp messaging. But I am assuming your local amqp is not up or might not be running properly or on wrong port. - doedotdev
The amqp versions supported by both programs are different. - Cipher

2 Answers

1
votes

Pika uses AMQP 0.9 and ActiveMQ uses 1.0. These protocols are incompatible.

Read the very beginning of the Pika docs.

Read the first line in the ActiveMQ AMQP docs.

0
votes

Looks like the connection params default to the proper settings.

Try just

import amqp

USER = "guest"
PASSWORD = "guest"
HOST = '/'
PORT = '5672'

host = HOST + ":" + PORT

conn = amqp.connection.Connection()
conn.connect()
print(conn.is_closing)

If you look at the implementation of Connection() it is

def __init__(self, host='localhost:5672', userid='guest', password='guest',
                 login_method=None, login_response=None, 

...

So it defaults to the correct stuff and runs for me locally using rabbit mq.

Hope this helps!