我使用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:服务器意外关闭连接
答案 0 :(得分:1)
答案 1 :(得分:0)
看起来连接参数默认为正确的设置。
尝试
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,
...
因此它默认为正确的内容,并使用Rabbit mq在本地为我运行。
希望这会有所帮助!