rabbitmq / rabbitmq-amqp1.0

AMQP 1.0 support for RabbitMQ
https://www.rabbitmq.com/
Other
93 stars 20 forks source link

Qpid C++ client runs into an exception #91

Closed szegel closed 4 years ago

szegel commented 5 years ago

Hello All,

RabbitMQ AMQP 1.0 errors out and closes the session when an Apache Qpid C++ client receive() call times out. The RabbitMQ server should not close the session, or throw an error when the Qpid C++ client receive() call times out.

I wrote this bug on QPID C++ API: https://issues.apache.org/jira/browse/QPID-8347 I believe that some part of it may be related to the RabbitMQ server.

Source:

#include <qpid/messaging/Connection.h>
#include <qpid/messaging/Message.h>
#include <qpid/messaging/Receiver.h>
#include <qpid/messaging/Sender.h>
#include <qpid/messaging/Session.h>

#include <iostream>

using namespace qpid::messaging;

int main(int argc, char** argv) {
    std::string broker = argc > 1 ? argv[1] : "localhost:5672";
    std::cout << "broker: " << broker << std::endl;
    std::string address = argc > 2 ? argv[2] : "topic.hello.world";
    std::cout << "address: " << address << std::endl;
    std::string connectionOptions = argc > 3 ? argv[3] : "";
    std::cout << "connectionOptions: " << connectionOptions << std::endl;

    try {
        Connection connection(broker, connectionOptions);
        connection.open();
        Session session = connection.createSession();

        Receiver receiver = session.createReceiver(address);
        Message message;
        std::cout << "Pre Receive" << std::endl;
    message = receiver.fetch(Duration::SECOND * 10);
        std::cout << "Post Receive" << std::endl;
        session.acknowledge();

        connection.close();
        return 0;
    } catch(const std::exception& error) {
        std::cerr << error.what() << std::endl;
        return 1;
    }
}

Output:

└─╼ ./hello_world 
broker: localhost:5672
address: topic.hello.world
connectionOptions: 
Pre Receive
Session ended by peer with amqp:internal-error: {{badmatch,{empty,{[],[]}}},[{amqp_channel,rpc_bottom_half,2,[{file,[115,114,99,47,97,109,113,112,95,99,104,97,110,110,101,108,46,101,114,108]},{line,623}]},{amqp_channel,handle_method_from_server1,3,[{file,[115,114,99,47,97,109,113,112,95,99,104,97,110,110,101,108,46,101,114,108]},{line,800}]},{gen_server,try_dispatch,4,[{file,[103,101,110,95,115,101,114,118,101,114,46,101,114,108]},{line,637}]},{gen_server,handle_msg,6,[{file,[103,101,110,95,115,101,114,118,101,114,46,101,114,108]},{line,711}]},{proc_lib,init_p_do_apply,3,[{file,[112,114,111,99,95,108,105,98,46,101,114,108]},{line,249}]}]}

Server Error (Occurs at timeout, 10 seconds in)

Configuration: OS: Ubuntu Bionic QPID C++ version 1.39.0 QPID Proton version 0.28.0 RabbitMQ Broker version 3.7.17-1 Erlang version 21.3.x RabbimtMQ AMQP 1.0 plugin Version 3.7.17

michaelklishin commented 5 years ago

You are confusing the cause and the effect here. RabbitMQ does not close its session because of a client timeout; it cannot be possibly aware of one. What happens is the plugin runs into an exception and that closes the connection and results in a client-side timeout.

szegel commented 5 years ago

Agreed, thanks for pointing me in the right direction.

szegel commented 5 years ago

Are there any plans to fix this any time soon?

michaelklishin commented 5 years ago

We do not offer an ETA for specific issues. Right now the priority is finishing RabbitMQ 3.8.0. As far as we can tell, this is something specific to one client.

This is open source software so you are welcome to contribute.

On Fri, 23 Aug 2019 at 00:07, szegel notifications@github.com wrote:

Are there any plans to fix this any time soon?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rabbitmq/rabbitmq-amqp1.0/issues/91?email_source=notifications&email_token=AAAAIQUITHNUIDYQNIVKUR3QF35ZNA5CNFSM4IHVXQ62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD46MYAI#issuecomment-524078081, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAAIQVOGELYIQAY42SLBOTQF35ZNANCNFSM4IHVXQ6Q .

-- Staff Software Engineer, Pivotal/RabbitMQ

kjnilsson commented 5 years ago

What may be helpful to help us investigate this issue is a wireshark capture of the AMQP frames for the simplest interaction that replicates the bug. Then we can see what actual values are passed and possibly reproduce it in our test suite.

engrstephens commented 4 years ago

3.8.1 resolves this issue.

michaelklishin commented 4 years ago

Interesting. I don't see any PRs that would link to it but we trust your judgement :) In case someone can reproduce it on 3.8.1 or later, let us know and we will reopen.

szegel commented 4 years ago

The test code now works as expected. The message that the qpid client gets from rabbitmq is no message, vs session closed.

szegel commented 4 years ago

And you can re-send over the same session after a timeout has occurred (which you couldn't do before).

michaelklishin commented 4 years ago

@szegel thank you for reporting back!