Antti / rust-amqp

AMQP client in pure rust. Corresponds to rabbitmq spec.
MIT License
249 stars 45 forks source link

Connection not closed/not receiving messages after ~5 minutes #52

Open Yoiink opened 7 years ago

Yoiink commented 7 years ago

Not really sure where the problem may be, you can find the connection code below.

All I'm doing is running the program, seeing it connect in RabbitMQ's Management, leave it for 5 minutes then close the program and the connection still shows in Management.

I think this also relates to an issue I'm having where in Management it looks like the message is being handled but does not ack after a long wait.

let amqp_url = "amqp://".to_string() + amqp_user.to_str().unwrap() + ":" + amqp_pass.to_str().unwrap() + "@rabbit-server/projectone";

let mut session = match Session::open_url(&amqp_url) {
    Ok(session) => session,
    Err(error) => 
        panic!("Can't create session: {:?}", error)
};

let mut channel = session.open_channel(1).ok().expect("Can't open channel");
println!("Opened channel: {}", channel.id);

let request_queue_name = "request";
let complete_queue_name = "complete";

let request_queue_declare = channel.queue_declare(request_queue_name, false, false, false, false, false, Table::new());
let complete_queue_declare = channel.queue_declare(complete_queue_name, false, false, false, false, false, Table::new());

let consumer_name = channel.basic_consume(consumer_function as ConsumerCallBackFn, request_queue_name, "",  false, false, false, false, Table::new());

let consumers_thread = thread::spawn(move || {
    channel.start_consuming();
    channel
});
jareddlc commented 6 years ago

I am also experiencing similar issue. After 5 mins of inactivity (not receiving messages) my application doesn't receive any subsequent messages, even though the rabbitmq management UI shows as connected, and receiving messages.

jareddlc commented 6 years ago

I think this may be due the client not having heartbeats. (https://www.rabbitmq.com/heartbeats.html) Depending of what version of rabbitmq server running, the default could be set to 580, and the interval heartbeats is set to 580/2 or 290 secs which is 4.8mins. After 2 failed heartbeats the connection is dropped.

magnusja commented 4 years ago

I am also experiencing similar issue. After 5 mins of inactivity (not receiving messages) my application doesn't receive any subsequent messages, even though the rabbitmq management UI shows as connected, and receiving messages.

exact same problem, any solution?