diff --git a/driver/failover_handler.cc b/driver/failover_handler.cc index 7ce68a836..e887c348f 100644 --- a/driver/failover_handler.cc +++ b/driver/failover_handler.cc @@ -75,8 +75,6 @@ const std::regex IPV6_COMPRESSED_PATTERN( R"#(^(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,5})?)::(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,5})?)$)#"); const char* MYSQL_READONLY_QUERY = "SELECT @@innodb_read_only AS is_reader"; - -const unsigned int MYSQL_PROXY_PORT = 8666; } // namespace FAILOVER_HANDLER::FAILOVER_HANDLER(DBC* dbc, DataSource* ds) @@ -371,11 +369,6 @@ bool FAILOVER_HANDLER::should_connect_to_new_writer(const char* host) { ds_set_wstrnattr(&ds->server, (SQLWCHAR*)writer_host_wstr.c_str(), writer_host_wstr.size()); ds_set_strnattr(&ds->server8, (SQLCHAR*)writer_host.c_str(), writer_host.size()); - // If we are updating to a proxied server, we need to also update the port to the proxy port. - if (writer_host.compare(writer_host.length() - 8, 8, ".proxied") == 0) { - ds->port = MYSQL_PROXY_PORT; - } - return true; } diff --git a/integration/base_failover_integration_test.cc b/integration/base_failover_integration_test.cc index e1b1bf25e..8c5221941 100644 --- a/integration/base_failover_integration_test.cc +++ b/integration/base_failover_integration_test.cc @@ -486,6 +486,12 @@ class BaseFailoverIntegrationTest : public testing::Test { } void test_connection(const SQLHDBC dbc, const std::string& test_server, const int test_port) { + sprintf(reinterpret_cast(conn_in), "%sSERVER=%s;PORT=%d;", get_default_config().c_str(), test_server.c_str(), test_port); + EXPECT_EQ(SQL_SUCCESS, SQLDriverConnect(dbc, nullptr, conn_in, SQL_NTS, conn_out, MAX_NAME_LEN, &len, SQL_DRIVER_NOPROMPT)); + EXPECT_EQ(SQL_SUCCESS, SQLDisconnect(dbc)); + } + + void test_connection_with_host_pattern(const SQLHDBC dbc, const std::string& test_server, const int test_port) { sprintf(reinterpret_cast(conn_in), "%sSERVER=%s;PORT=%d;", get_default_proxied_config().c_str(), test_server.c_str(), test_port); EXPECT_EQ(SQL_SUCCESS, SQLDriverConnect(dbc, nullptr, conn_in, SQL_NTS, conn_out, MAX_NAME_LEN, &len, SQL_DRIVER_NOPROMPT)); EXPECT_EQ(SQL_SUCCESS, SQLDisconnect(dbc)); diff --git a/integration/network_failover_integration_test.cc b/integration/network_failover_integration_test.cc index e9a7cde8c..f37f24b99 100644 --- a/integration/network_failover_integration_test.cc +++ b/integration/network_failover_integration_test.cc @@ -93,11 +93,11 @@ class NetworkFailoverIntegrationTest : public BaseFailoverIntegrationTest { TEST_F(NetworkFailoverIntegrationTest, connection_test) { test_connection(dbc, MYSQL_INSTANCE_1_URL, MYSQL_PORT); - test_connection(dbc, MYSQL_INSTANCE_1_URL + PROXIED_DOMAIN_NAME_SUFFIX, MYSQL_PROXY_PORT); + test_connection_with_host_pattern(dbc, MYSQL_INSTANCE_1_URL + PROXIED_DOMAIN_NAME_SUFFIX, MYSQL_PROXY_PORT); test_connection(dbc, MYSQL_CLUSTER_URL, MYSQL_PORT); - test_connection(dbc, MYSQL_CLUSTER_URL + PROXIED_DOMAIN_NAME_SUFFIX, MYSQL_PROXY_PORT); + test_connection_with_host_pattern(dbc, MYSQL_CLUSTER_URL + PROXIED_DOMAIN_NAME_SUFFIX, MYSQL_PROXY_PORT); test_connection(dbc, MYSQL_RO_CLUSTER_URL, MYSQL_PORT); - test_connection(dbc, MYSQL_RO_CLUSTER_URL + PROXIED_DOMAIN_NAME_SUFFIX, MYSQL_PROXY_PORT); + test_connection_with_host_pattern(dbc, MYSQL_RO_CLUSTER_URL + PROXIED_DOMAIN_NAME_SUFFIX, MYSQL_PROXY_PORT); } TEST_F(NetworkFailoverIntegrationTest, lost_connection_to_writer) {