On 29/03/2019 12:26 pm, Toralf Lund wrote:
Another one related to issues I've mentioned in other recent posts:

I'm doing some debugging related to undesired side effects in one of our applications after it gets a "Failed to connect (reconnect disabled)" error while sending to or receiving from the C++ broker. In then "manually" reopens the connection after a slight delay. As parts of the reconnect logic, I also tend to get "'session-busy: Session detached by peer'". This is possibly triggered by the connect itself, but it could also come from other operations done just after connecting.

This would be a whole lot easier if I could provoke the errors into occurring, so as to speak. I guess the "failed to connect" error means the broker has dropped the connection, but is there a way I can force it to do that (without restarting)? And how about the "Session detached by peer"? It's not clear to me when exactly I get that, but I guess it's related to sessions that existed before the connection was closed. Which (according to information I got here earlier) Connection::open() might try to recreate, but perhaps the operation fails? Can I somehow manipulate the state so I can find out more about the behaviour?

You can specify the name for the session when you create it. So one approach might be to connect your client (the one you want to test), then kill -STOP that client, then start a test client that just opens a session with the same name (e.g. see attached), then kill -CONT the client which should then failover (assuming heartbeats were on) and hit the session-busy error.
/*
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 *
 */

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

using namespace qpid::messaging;

int main(int argc, char** argv)
{
    Connection connection;
    try
    {
        std::string url = "localhost:5672";
        std::string address = "amq.fanout";
        std::string connectionOptions = "{}";
        std::string name = argc > 1 ? argv[1] : "my-session";

        connection = Connection(url, connectionOptions);
        connection.open();
        Session session = connection.createSession(name);
        Receiver receiver = session.createReceiver(address);
        Message m;
        receiver.fetch(m);

        return 0;
    } catch (const std::exception& error) {
        std::cout << "Error: " << error.what() << std::endl;
    }
    return 1;
}

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to