问题描述
我正在使用 pika python 库与 RabbitMQ 消息代理进行交互。
要创建连接,我使用:
def get_connection():
credential = pika.PlainCredentials(LOGIN,PASS)
parameters = pika.ConnectionParameters(
HOST,5672,'/',credential,heartbeat=0,blocked_connection_timeout=0
)
connection = pika.BlockingConnection(parameters)
return connection
进一步:
channel = get_connection().channel()
channel.basic_consume(queue='test',on_message_callback=run)
channel.start_consuming()
run
函数执行长时间计算(约 30 分钟),然后调用 ch.basic_ack(method.delivery_tag)
,但出现错误:
StreamLostError: Stream connection lost: ConnectionResetError(104,'Connection reset by peer')
我不知道我需要做什么来避免这个错误。我更改了心跳参数的值,但没有帮助
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)