fix bug: error about missing openssl was also reported when not even opening a secure connection
This commit is contained in:
parent
9a08c64ff7
commit
cea5a54487
|
|
@ -66,20 +66,30 @@ int main()
|
||||||
MyHandler handler(loop);
|
MyHandler handler(loop);
|
||||||
|
|
||||||
// init the SSL library
|
// init the SSL library
|
||||||
SSL_library_init();
|
// SSL_library_init();
|
||||||
|
|
||||||
// make a connection
|
// make a connection
|
||||||
AMQP::Address address("amqps://guest:guest@localhost/");
|
AMQP::Address address("amqp://guest:guest@localhost/");
|
||||||
AMQP::TcpConnection connection(&handler, address);
|
AMQP::TcpConnection connection(&handler, address);
|
||||||
|
|
||||||
// we need a channel too
|
// we need a channel too
|
||||||
AMQP::TcpChannel channel(&connection);
|
AMQP::TcpChannel channel(&connection);
|
||||||
|
|
||||||
// create a temporary queue
|
// create a temporary queue
|
||||||
channel.declareQueue(AMQP::exclusive).onSuccess([&connection](const std::string &name, uint32_t messagecount, uint32_t consumercount) {
|
channel.declareQueue(AMQP::exclusive).onSuccess([&connection, &channel](const std::string &name, uint32_t messagecount, uint32_t consumercount) {
|
||||||
|
|
||||||
// report the name of the temporary queue
|
// report the name of the temporary queue
|
||||||
std::cout << "declared queue " << name << std::endl;
|
std::cout << "declared queue " << name << std::endl;
|
||||||
|
|
||||||
|
// close the channel
|
||||||
|
channel.close().onSuccess([&connection, &channel]() {
|
||||||
|
|
||||||
|
// report that channel was closed
|
||||||
|
std::cout << "channel closed" << std::endl;
|
||||||
|
|
||||||
|
// close the connection
|
||||||
|
connection.close();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// run the loop
|
// run the loop
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ namespace AMQP {
|
||||||
* @param hostname The address to connect to
|
* @param hostname The address to connect to
|
||||||
*/
|
*/
|
||||||
TcpConnection::TcpConnection(TcpHandler *handler, const Address &address) :
|
TcpConnection::TcpConnection(TcpHandler *handler, const Address &address) :
|
||||||
// _state(new TcpResolver(this, address.hostname(), address.port(), address.secure(), handler)),
|
_state(new TcpResolver(this, address.hostname(), address.port(), address.secure(), handler)),
|
||||||
_connection(this, address.login(), address.vhost()) {}
|
_connection(this, address.login(), address.vhost()) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -133,14 +133,8 @@ void TcpConnection::onHeartbeat(Connection *connection)
|
||||||
*/
|
*/
|
||||||
void TcpConnection::onError(Connection *connection, const char *message)
|
void TcpConnection::onError(Connection *connection, const char *message)
|
||||||
{
|
{
|
||||||
// current object is going to be removed, but we have to keep it for a while
|
|
||||||
auto ptr = std::move(_state);
|
|
||||||
|
|
||||||
// object is now in a closed state
|
|
||||||
//_state.reset(new TcpClosed(ptr.get()));
|
|
||||||
|
|
||||||
// tell the implementation to report the error
|
// tell the implementation to report the error
|
||||||
ptr->reportError(message);
|
_state->reportError(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ private:
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// check if we support openssl in the first place
|
// check if we support openssl in the first place
|
||||||
if (!OpenSSL::valid()) throw std::runtime_error("Secure connection cannot be established: libssl.so cannot be loaded");
|
if (_secure && !OpenSSL::valid()) throw std::runtime_error("Secure connection cannot be established: libssl.so cannot be loaded");
|
||||||
|
|
||||||
// get address info
|
// get address info
|
||||||
AddressInfo addresses(_hostname.data(), _port);
|
AddressInfo addresses(_hostname.data(), _port);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue