diff --git a/dbms/src/Client/Connection.cpp b/dbms/src/Client/Connection.cpp index 4120bed14fc..3e13b906a74 100644 --- a/dbms/src/Client/Connection.cpp +++ b/dbms/src/Client/Connection.cpp @@ -95,7 +95,8 @@ void Connection::disconnect() { //LOG_TRACE(log_wrapper.get(), "Disconnecting"); - socket->close(); + if (socket) + socket->close(); socket = nullptr; in = nullptr; out = nullptr; diff --git a/dbms/src/Core/Defines.h b/dbms/src/Core/Defines.h index 820b9fc15fd..df0d59702aa 100644 --- a/dbms/src/Core/Defines.h +++ b/dbms/src/Core/Defines.h @@ -6,6 +6,7 @@ #define DBMS_DEFAULT_HOST "localhost" #define DBMS_DEFAULT_PORT 9000 +#define DBMS_DEFAULT_SECURE_PORT 9443 #define DBMS_DEFAULT_PORT_STR #DBMS_DEFAULT_PORT #define DBMS_DEFAULT_HTTP_PORT 8123 #define DBMS_DEFAULT_CONNECT_TIMEOUT_SEC 10 diff --git a/dbms/src/Server/Client.cpp b/dbms/src/Server/Client.cpp index 46e70e2d745..4a8e0b4743a 100644 --- a/dbms/src/Server/Client.cpp +++ b/dbms/src/Server/Client.cpp @@ -375,8 +375,12 @@ private: void connect() { + Protocol::Encryption::Enum encryption = config().getBool("secure", false) + ? Protocol::Encryption::Enable + : Protocol::Encryption::Disable; + String host = config().getString("host", "localhost"); - UInt16 port = config().getInt("port", DBMS_DEFAULT_PORT); + UInt16 port = config().getInt("port", config().getInt(encryption ? "tcps_port" : "tcp_port", encryption ? DBMS_DEFAULT_SECURE_PORT : DBMS_DEFAULT_PORT)); String default_database = config().getString("database", ""); String user = config().getString("user", ""); String password = config().getString("password", ""); @@ -385,9 +389,6 @@ private: ? Protocol::Compression::Enable : Protocol::Compression::Disable; - Protocol::Encryption::Enum encryption = config().getBool("secure", true) - ? Protocol::Encryption::Enable - : Protocol::Encryption::Disable; if (is_interactive) std::cout << "Connecting to " << (!default_database.empty() ? "database " + default_database + " at " : "")