ClickHouse / clickhouse-cpp

C++ client library for ClickHouse
Apache License 2.0
300 stars 154 forks source link

ProtocolError: Fail to connect to server #388

Open DKGH opened 1 week ago

DKGH commented 1 week ago

I am getting the error mentioned in the subject line while trying to connect to a clickhouse server using host, port, username, and password. How can I get more details about why this error happened?

1261385937 commented 6 days ago

please show you simple code @DKGH

DKGH commented 4 days ago

It is a modified version of tests/simple/main.cpp from the GitHub codebase:

int main() {
try {
  const auto localhost = ClientOptions().SetHost("hostname").SetPort(8080).SetUser("user").SetPassword("password");
  Client client(localhost);
} catch (const ProtocolError & e) {
  cout << e.what();
} catch (const std:: exception& e) {
  cout << e.what();
}
return 0;
}