我使用amqp客户端连接ActiveMQ代理。
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()
获取错误:OSError:服务器意外关闭连接
看起来连接参数默认为正确的设置。
试试吧
import amqp
USER = "guest"
PASSWORD = "guest"
HOST = '/'
PORT = '5672'
host = HOST + ":" + PORT
conn = amqp.connection.Connection()
conn.connect()
print(conn.is_closing)
如果你看一下Connection()的实现
def __init__(self, host='localhost:5672', userid='guest', password='guest',
login_method=None, login_response=None,
...
所以它默认为正确的东西,并使用兔子mq本地运行。
希望这可以帮助!