Skip to content

Commit

Permalink
Bugfix: Clickhouse connect a closed network that will crash process.
Browse files Browse the repository at this point in the history
  • Loading branch information
i0gan committed Mar 9, 2024
1 parent 1f4c74b commit 8f124b3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/node/db_proxy/clickhouse/clickhouse_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,14 @@ bool ClickhouseModule::Connect() {
int port = m_element_->GetPropertyInt32(id, excel::DB::Port());
string password = m_element_->GetPropertyString(id, excel::DB::Auth());
/// Initialize client connection.
client_ = new Client(ClientOptions().SetHost(ip).SetPort(port).SetPassword(password));

try {
client_ = new Client(ClientOptions().SetHost(ip).SetPort(port).SetPassword(password));
}
catch (const std::exception& e) {
std::cout << "Click connect error: " << e.what() << std::endl;
return false;
}

// Create a table.
client_->Execute("CREATE TABLE IF NOT EXISTS default.numbers (id UInt64, name String) ENGINE = Memory");

Expand Down

0 comments on commit 8f124b3

Please sign in to comment.