gpt4 book ai didi

ios - 无法使用 Swift 连接 RabbitMQ

转载 作者:行者123 更新时间:2023-11-30 13:12:55 24 4
gpt4 key购买 nike

我开始将 RabbitMQ 与 Swift 结合使用。我按照 github 上的 RabbitMQ 库中的示例代码进行操作:

let delegate = RMQConnectionDelegateLogger() 
let conn = RMQConnection(uri: "amqp://localhost:5672", delegate: delegate)

conn.start()

let ch = conn.createChannel()

let q = ch.queue("hello")
q.subscribe { rm in
print(rm.content )
}

我多次遇到这些错误:

Will start recovery for connection: <' Received connection: <'RMQConnection: 0x7fdb43c73670> disconnectedWithError: Error Domain=GCDAsyncSocketErrorDomain Code=7 "Socket closed by remote peer" UserInfo={NSLocalizedDescription=Socket closed by remote peer}RMQConnection: 0x7fdb43c73670>

在 RabbitMQ 日志上我收到此错误:

Error on AMQP connection <0.271.0> (172.19.0.1:53144 -> 172.19.0.4:5672, state: starting): PLAIN login refused: user '' - invalid credentials

我可以在哪里定义凭据?我搜索了很多例子但找不到任何东西。

最佳答案

检查一下:

Can't access RabbitMQ web management interface after fresh install

然后将 URL 连接更改为:

'amqp://test:test@localhost:5672/'

关于ios - 无法使用 Swift 连接 RabbitMQ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38538340/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com