alanxz/SimpleAmqpClient

Unhandled auth type Exception

ericliu1990 opened this issue · 0 comments

Hello,

The Unhandled auth type Exception was encountered during the development.

here is my development environment:

boost: 1_74_0
rabbitmq-c v0.10.0
SimpleAmqpClient v2.5.1
CMAKE 3.18.3
windows server 2016
virtual studio 2019

here is my client c++ code:

AmqpClient::Channel::OpenOpts opts;
        opts.host = "10.8.10.50";
        opts.port = 5672;
        opts.auth = AmqpClient::Channel::OpenOpts::BasicAuth("admin", "admin");
        
        std::cout<< opts.auth.which() << std::endl;  // the output is 0 here
        AmqpClient::Channel::ptr_t inputChannel = AmqpClient::Channel::Open(opts);

when I tried to debug,
in the file : .\SimpleAmqpClient\src\Channel.cpp line 200

i added one line to print the opts.auth.which(), when the client try to call AmqpClient::Channel::Open, the output of opts.auth.which() is a random number here eg. 995360767 as shown below:

std::cout<< "opts.auth.which()" << opts.auth.which() << std::endl; // the output is random number here eg. 995360767

  if (!opts.tls_params.is_initialized()) {
    switch (opts.auth.which()) {
      case 0: {
        const OpenOpts::BasicAuth &auth =
            boost::get<OpenOpts::BasicAuth>(opts.auth);
        return boost::make_shared<Channel>(
            OpenChannel(opts.host, opts.port, auth.username, auth.password,
                        opts.vhost, opts.frame_max, false));
      }
      case 1: {
        const OpenOpts::ExternalSaslAuth &auth =
            boost::get<OpenOpts::ExternalSaslAuth>(opts.auth);
        return boost::make_shared<Channel>(
            OpenChannel(opts.host, opts.port, auth.identity, "", opts.vhost,
                        opts.frame_max, true));
      }
      default:
        throw std::logic_error("Unhandled auth type");
    }
  }
  switch (opts.auth.which()) {
    case 0: {
      const OpenOpts::BasicAuth &auth =
          boost::get<OpenOpts::BasicAuth>(opts.auth);
      return boost::make_shared<Channel>(OpenSecureChannel(
          opts.host, opts.port, auth.username, auth.password, opts.vhost,
          opts.frame_max, opts.tls_params.get(), false));
    }
    case 1: {
      const OpenOpts::ExternalSaslAuth &auth =
          boost::get<OpenOpts::ExternalSaslAuth>(opts.auth);
      return boost::make_shared<Channel>(
          OpenSecureChannel(opts.host, opts.port, auth.identity, "", opts.vhost,
                            opts.frame_max, opts.tls_params.get(), true));
    }
    default:
      throw std::logic_error("Unhandled auth type");
  }

in the end it will go to default which will return "Unhandled auth type"

any idea what's wrong?

Thanks in advance!