我正在使用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')
我不知道我需要做什么来避免这个错误。我更改了心跳参数的值,但没有任何帮助
目前没有回答
相关问题 更多 >
编程相关推荐